fix(variable:create): resolve "-e ." default-environment placeholder#125
Open
pjcdawkins wants to merge 2 commits into
Open
fix(variable:create): resolve "-e ." default-environment placeholder#125pjcdawkins wants to merge 2 commits into
pjcdawkins wants to merge 2 commits into
Conversation
Creating a variable with `-e .` selected the default environment correctly, then crashed with `In Field.php line 252: . is not one of: ...`. The command builds a ConsoleForm whose `environment` field validates the `--environment` option against the list of real environment IDs before normalization. The selector had already resolved `.` to the default environment, but the form validated the literal placeholder. Replace the default-environment placeholder in the `--environment` option with the resolved environment ID after selection, so the form validates a real ID. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in variable:create when users select the default environment via -e . by normalizing the placeholder value (.) to the resolved environment ID before ConsoleForm option validation runs.
Changes:
- Normalize
--environmentfrom the default-environment placeholder (.) to the resolved environment ID after selection, preventingOptionsFieldvalidation from rejecting.. - Add an integration regression test covering
var:create -e .and verifying the variable is created on the default environment.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| legacy/src/Command/Variable/VariableCreateCommand.php | Rewrites --environment from . to the resolved environment ID after selector resolution so form validation uses a real environment ID. |
| integration-tests/variable_write_test.go | Adds a regression test ensuring var:create -e . does not fail validation and creates the variable on the default environment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The command line is within the length limit, so the directive was flagged as unused by nolintlint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Creating a variable with
-e .selected the default environment correctly, then crashed:Cause
variable:createbuilds aConsoleFormwhoseenvironmentfield is anOptionsField. DuringresolveOptions()the form re-reads the raw--environmentoption value (.) and validates it against the list of real environment IDs, before normalization. The selector had already resolved.to the default environment, but the form validated the literal placeholder and threw.variable:updateis not affected — it unsets theenvironmentfield from its form.Fix
After the selector resolves the selection, replace the default-environment placeholder (
.) in the--environmentoption with the resolved environment ID, so the form validates a real ID. Guarded on the value being exactly the placeholder, so explicit environment names and the no--ecase are untouched.Added an integration test (
TestVariableCreateDefaultEnvironment) that reproduces the crash and confirms the variable is created on the default environment.🤖 Generated with Claude Code