Skip to content

Convert all non-string configuration properties in debug #115

Closed

Description

@Fedma123

Requested feature

Support port numbers in attach debug configurations as strings rather than numbers exclusively.

{
    "name": "Python: Current File",
    "type": "python",
    "request": "attach",
    "connect": {
        "host": "localhost",
        "port": "1234"
    }

Motivation

The attach debug configurations expect a number as port number rather than a string. This prevents variable substitution in launch.json. As an example, the following configuration raises an error on the port key: Incorrect type. Expected "number".

{
    "name": "Python: Current File",
    "type": "python",
    "request": "attach",
    "connect": {
        "host": "localhost",
        "port": "${env:DEFAULT_DEBUGGER_PORT}"
    },
    "console": "integratedTerminal"
}

Use case

Assume that you have to debug your application by attaching to a running process. Assume that you package and debug the application into a container by attaching VSCode to the running container. Finally, assume that you have to debug parallel instances of the application on your local machine. In this scenario each debugger must use a distinct port (this is the case for containers in a podman pod at least because they share the same network). The port could be supplied as an environment variable to each container.

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    feature-requestRequest for new features or functionality
    on Nov 18, 2021
  2. karthiknadig commented on Nov 18, 2021

    @karthiknadig
    Member

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  3. karthiknadig commented on Nov 18, 2021

    @karthiknadig
    Member
  4. int19h commented on Nov 18, 2021

    @int19h

    Note that we already did this for processId before, and for the same exact reason.

    Given that it's the second property like that, and that it's hard to predict all the scenarios in which variable substitution might be useful for one property or another, I feel like this should be generalized to all numeric properties. On debugpy side this would be easy, since there's a common path for all typed property queries. However, connect.port for attach is a separate thing, because it's handled entirely by vscode-python.

  5. brettcannon commented on Feb 3, 2022

    @brettcannon
    Member

    Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.

    We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.

  6. dyohn commented on Sep 13, 2022

    @dyohn

    I found this issue as I was preparing to make the exact same feature request! I have a situation where a team of developers needs to actively debug multiple containerized micro-services at once. This works just fine, but the caveat is that that everyone has to modify their local launch.json file to hard code their various debug ports. Obviously, those changes can't be checked into source control without causing tons of useless and contentious changes. Having the ability to specify these ports via environment variables would be much cleaner and less error prone! I really hope this story gets worked; if I knew how/where to make the change I would be willing to pitch in. Alas, I am a poor excuse for a TypeScript developer.

  7. TheDouglasMann commented on Sep 13, 2022

    @TheDouglasMann

    Definitely need this!

  8. int19h commented on Sep 26, 2022

    @int19h

    Isn't this a dupe of microsoft/vscode-python#18841?

  9. dyohn commented on Sep 26, 2022

    @dyohn

    Isn't this a dupe of microsoft/vscode-python#18841?

    18441 handled this case for the listen configuration only. I can't speculate on the how/why of that, but I know for sure that the connect configuration will only accept an integer for port, at least as of VS Code 1.71.1 and Python Extension 2022.14.0. I get the following when I try:

    launchJsonError

  10. 14 remaining items

  11. andreamah commented on Nov 28, 2023

    @andreamah

    Are there short verif steps for this feature?

  12. rzhao271 commented on Nov 29, 2023

    @rzhao271
    Contributor

    I still can't specify the port as a string in a Python attach launch configuration, so it looks like the original request still isn't fixed.

    Python launch configuration indicating a type error when the port is "1234" because it's a string

  13. paulacamargo25 commented on Nov 29, 2023

    @paulacamargo25
    Contributor

    This issue was solved in the Python Debugger Extension.
    Please use the "type": "debugpy" for the configuration.

  14. rzhao271 commented on Nov 29, 2023

    @rzhao271
    Contributor

    LGTM. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestRequest for new features or functionalityverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions