diff --git a/src/debugpy/server/cli.py b/src/debugpy/server/cli.py index ff117094..56974891 100644 --- a/src/debugpy/server/cli.py +++ b/src/debugpy/server/cli.py @@ -218,7 +218,8 @@ def parse_args(): parse_args_from_command_line(seen) parse_args_from_environment(seen) - if options.target is None: + # if the target is not set, or is empty, this is an error + if options.target is None or not options.target.strip(): raise ValueError("missing target: " + TARGET) if options.mode is None: @@ -228,7 +229,6 @@ def parse_args(): if options.target_kind == "pid" and options.wait_for_client: raise ValueError("--pid does not support --wait-for-client") - assert options.target is not None assert options.target_kind is not None assert options.address is not None diff --git a/tests/debugpy/server/test_cli.py b/tests/debugpy/server/test_cli.py index 141d3266..28bda085 100644 --- a/tests/debugpy/server/test_cli.py +++ b/tests/debugpy/server/test_cli.py @@ -180,7 +180,7 @@ def test_address_required(cli): def test_missing_target(cli): with pytest.raises(ValueError) as ex: - cli(["--listen", "8888"]) + cli(["--listen", "8888", "-m", ""]) assert "missing target" in str(ex.value)