Skip to content

API: create environment with name - #1802

Open
Eduardo Villalpando Mello (edvilme) wants to merge 1 commit into
mainfrom
api-environment-name
Open

Eduardo Villalpando Mello (edvilme) wants to merge 1 commit into
mainfrom
api-environment-name

Conversation

@edvilme

Copy link
Copy Markdown
Contributor

This pull request introduces a new optional name field to the CreateEnvironmentOptions for the @vscode/python-environments API, allowing API consumers to specify a desired environment name when creating Python environments. The implementation ensures that provided names are validated and integrated into both venv and conda environment creation flows. Documentation and versioning are updated accordingly.

API and Documentation Updates:

  • Added an optional name property to CreateEnvironmentOptions, enabling consumers to request a specific environment name during creation. The documentation (docs/README.md) and changelog (api/CHANGELOG.md) are updated to reflect this new feature. [1] [2] [3] [4]

  • Bumped package version to 1.5.0 in package.json and package-lock.json. [1] [2]

Validation and Core Logic:

  • Implemented validation for the name field to ensure it is a non-empty path segment and does not contain invalid characters (e.g., ., .., /, This pull request introduces a new optional namefield to theCreateEnvironmentOptionsfor the@vscode/python-environments` API, allowing API consumers to specify a desired environment name when creating Python environments. The implementation ensures that provided names are validated and integrated into both venv and conda environment creation flows. Documentation and versioning are updated accordingly.

API and Documentation Updates:

  • Added an optional name property to CreateEnvironmentOptions, enabling consumers to request a specific environment name during creation. The documentation (docs/README.md) and changelog (api/CHANGELOG.md) are updated to reflect this new feature. [1] [2] [3] [4]

  • Bumped package version to 1.5.0 in package.json and package-lock.json. [1] [2]

Validation and Core Logic:

, or null bytes).

Venv Environment Creation:

  • Updated venv creation flows to accept and use the supplied name, including validation for existing directories and proper handling in both quick and step-based flows. The state management is enhanced to track if the name was supplied by the user. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Conda Environment Creation:

  • Extended conda environment creation flows to support the optional name parameter, ensuring correct flow control, state management, and back-navigation logic. The implementation also ensures that the environment is created with the requested name if provided. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

@edvilme Eduardo Villalpando Mello (edvilme) added the feature-request Request for new features or functionality label Sep 22, 2026
@edvilme
Eduardo Villalpando Mello (edvilme) marked this pull request as ready for review September 22, 2026 16:42
Comment thread docs/README.md

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | No | Non-empty path segment to use as the new environment's name. Directory separators, `.` and `..` are rejected. When supplied, the manager uses that name without prompting for another. When omitted, the manager may prompt for a name or choose a default. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'No' seems like a weird value for a string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think true/false is better

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it means that it is not required

envCreationErr: 'No suitable Python environments found',
};
}
if (options.name !== undefined && (await fse.pathExists(path.join(venvRoot.fsPath, options.name)))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the name need to be validated as an allowed path string?

@bschnurr

Bill Schnurr (bschnurr) commented Sep 22, 2026

Copy link
Copy Markdown
Member

🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR.

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the name needs to be validated to contain allowed path characters.

For example, I don't think a name of ..\..\ would work very well.

Comment thread src/extensionApi.ts
options.name.includes('\\') ||
options.name.includes('\0'))
) {
throw new Error('Environment name must be a non-empty path segment');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Non-blocking recommendation

The advertised path-segment validation accepts Windows-invalid or ambiguous names such as python:3.12, CON, and names ending with a dot or space. Define and test a portable shared name validator, or explicitly document platform-specific restrictions and have each manager reject invalid names before creation.

[verified]

@bschnurr Bill Schnurr (bschnurr) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@bschnurr Bill Schnurr (bschnurr) added the review-auto:approved Automated review: no blocking findings (approval posted). label Sep 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

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

Labels

feature-request Request for new features or functionality review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants