fix(environment:delete): handle a single wildcard or missing environment - #179
Merged
Merged
Conversation
The project selector was given the original input instead of the copy with the environment argument and option cleared, so a single environment argument (or -e) was resolved as an exact ID and failed with "Specified environment not found" before wildcards were applied. Exact IDs that don't match any environment were also dropped by Wildcard::select(), so the command's own "not found" refresh and error never ran. Keep exact IDs so they are reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the environment argument and option cleared, the selector still fell back to the <prefix>BRANCH environment variable and failed if it named an unknown environment, blocking explicit deletions. Add a selectEnv option to SelectorConfig to skip environment selection, and use it instead of clearing the input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Reviewed — No blocking findings · 🔵 1 minor point
🔍 Full review · 4 files reviewed
🔵 Minor point
integration-tests/environment_delete_test.go:61— The test case "ignores an unknown branch variable" passes an environment argument (test-1) along withPLATFORM_BRANCH=missing. It would have passed before this fix too. When theenvironmentargument is not empty, the oldSelector::getSelection()took the argument branch and calledselectEnvironment($input, $project, $config, 'test-1'). That call gets a non-null$environmentId, soselectEnvironmentnever reads<prefix>BRANCH; the variable is only read when$environmentId === null.<prefix>BRANCHblocked deletion only when no argument and no-ewere given, for exampleenvironment:delete --inactiveor--mergedor--type .... In that case the selector'selseif ($input->hasOption('environment'))branch passed null, fell back toPLATFORM_BRANCH, and threw "Specified environment not found". Nothing covers that case, so a regression in theselectEnv: falsepath for flag-only deletions would go unnoticed.
Verification
- All ~50
new SelectorConfig(...)call sites in legacy/src pass named arguments, so addingselectEnvas the second constructor parameter moves no one's positional arguments. envRequiredis read only insideselectEnvironment, whichselectEnv: falsenow skips, so droppingenvRequired: falsefrom the delete command changes nothing.- The delete command never used
$selection->getEnvironment(); its no-argument fallback callsgetCurrentEnvironment(), which is Git-based. Skipping environment selection loses no behaviour. - The exact-ID merge keeps wildcard matches first, then adds exact IDs that match nothing, so they reach the refresh and the "Environment not found" error;
array_uniqueremoves the duplicates.
The PR adds integration-tests/environment_delete_test.go with four cases (wildcard argument, wildcard -e option, unknown PLATFORM_BRANCH, missing environment), run against the mock API. These tests need a built binary under dist/ and skip themselves if there isn't one. The PLATFORM_BRANCH case doesn't exercise the path that was actually broken, and nothing tests flag-only deletions such as --inactive with a branch variable set.
Review details
- Commit: 4dc71f1
- Model: claude-opus-5-5
Review 1 of 10 for this pull request · View the full run
…flags The previous case passed an environment argument, so the selector never read <prefix>BRANCH and the case passed without the fix. Use --type instead, which reached the fallback before selectEnv was added. Co-Authored-By: Claude Opus 5.5 <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.
environment:deletefailed with "Specified environment not found" when given a single wildcard ('test-*'or-e 'test-*'), because the project selector received the original input and tried to resolve the argument as an exact environment ID.Changes:
selectEnvoption toSelectorConfigto select only the project, and use it inenvironment:delete. This also stops an unknown<prefix>BRANCHvalue from blocking explicit deletions.Wildcard::select()).🤖 Generated with Claude Code