API: create environment with name - #1802
Eduardo Villalpando Mello (edvilme) wants to merge 1 commit into
Conversation
|
|
||
| | 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. | |
There was a problem hiding this comment.
'No' seems like a weird value for a string
There was a problem hiding this comment.
i think true/false is better
There was a problem hiding this comment.
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)))) { |
There was a problem hiding this comment.
Does the name need to be validated as an allowed path string?
|
🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR. |
Rich Chiodo (rchiodo)
left a comment
There was a problem hiding this comment.
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.
| options.name.includes('\\') || | ||
| options.name.includes('\0')) | ||
| ) { | ||
| throw new Error('Environment name must be a non-empty path segment'); |
There was a problem hiding this comment.
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]
Bill Schnurr (bschnurr)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
Stella Huang (StellaHuang95)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
This pull request introduces a new optional
namefield to theCreateEnvironmentOptionsfor the@vscode/python-environmentsAPI, 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
nameproperty toCreateEnvironmentOptions, 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.0inpackage.jsonandpackage-lock.json. [1] [2]Validation and Core Logic:
namefield to ensure it is a non-empty path segment and does not contain invalid characters (e.g.,.,..,/,This pull request introduces a new optionalnamefield 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
nameproperty toCreateEnvironmentOptions, 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.0inpackage.jsonandpackage-lock.json. [1] [2]Validation and Core Logic:
, or null bytes).
Venv Environment Creation:
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:
nameparameter, 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]