Repository navigation
fix: spawn list --state all means no filter, not a literal "all" filter (#527) - #535
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…er (#527) --state all was passed straight through to EC2 as a literal instance-state-name filter value. No instance is ever literally in state "all", so the filter matched nothing: exit 0, a well-formed empty JSON array, reading exactly like a clean account even when instances existed. This is the command the docs recommend for "did anything leak?", so the bug gave false confidence at the worst possible moment. Fix: "all" and the alias "any" now mean no state filter at all — a genuine superset of the default that also surfaces terminated/shutting-down instances (AWS retains those for about an hour). The no-flag default (pending/running/stopping/stopped) is unchanged. Any other unrecognized --state value (a typo like "runing", or wrong case like "ALL") is now a hard, non-zero-exit error naming the valid states, instead of silently degrading to an empty result. Tests: - pkg/aws: TestValidateStateFilter (pure unit test for the alias/validation logic) and TestClient_ListInstances_StateAll (superset behavior against Substrate: running + terminated instances, default excludes terminated, bogus state errors). - test/e2e/tier0_list_state_test.go (Tier 0, Substrate-backed): the primary regression is TestTier0_ListStateAll_ReturnsRunningAndTerminated (--state all/any returns both a running and a terminated instance). TestTier0_ListStateBogus_ErrorsNotEmpty is the most important negative case — it explicitly asserts the output is NOT "[]" on exit 0, which is the exact spawn#527 failure mode a weaker "valid JSON" check would miss. Wrong-case ("ALL") and typo ("runing") cases are covered separately. All new tests were verified to fail against the pre-fix code (temporarily reverted both the filter-building switch and validateStateFilter) and pass with the fix restored. make check is clean; full Tier 0 e2e suite passes.
scttfrdmn
force-pushed
the
fix/527-list-state-all
branch
from
August 19, 2026 21:40
8ff9e8c to
f5c5524
Compare
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.
Closes #527.
The bug
spawn list --state allreturned an empty list always, regardless of how many instances existed."all"was passed straight through to EC2 as a literalinstance-state-namefilter value, and no instance is ever literally in state"all", so the filter matched nothing. Exit code 0, output a well-formed empty JSON array — reads exactly like a clean account even when it isn't.pkg/aws/client.go(listInstancesInRegion) had no"all"case at all:cmd/list.gobound--stateas a free-form string and handed it toListInstancesunmodified, so any typo (runing) or case mismatch (ALL) hit the same silent-empty-result path. This is documented in the spore-host docs as the way to check "did anything leak?" —spawn list --state all— so the bug gave false confidence at exactly the moment it mattered most.The fix
Two changes in
pkg/aws/client.go:"all"/"any"now mean "no state filter" — a genuine superset of the default, includingterminated/shutting-downinstances (AWS retains those for about an hour after termination, so this is expected, not a regression to guard against). This is expressed by omitting theinstance-state-namefilter entirely inlistInstancesInRegion, rather than passing"all"through as a literal value:A new
validateStateFilter, called at the top ofListInstancesbefore any region is queried, rejects anything that isn't"","all"/"any", or a real EC2instance-state-name(pending,running,shutting-down,terminated,stopping,stopped).--state bogus,--state ALL(wrong case), and--state runing(typo) are now hard errors naming the valid values, not silent empty results.The no-flag default (
pending,running,stopping,stopped) is unchanged.cmd/list.go's--stateflag help text now documents theall/anyalias.The regression tests
Unit (
pkg/aws, no AWS account needed):TestValidateStateFilter— pure-function coverage of every valid value (including case-sensitivity:ALL/Allmust fail) and every invalid one, asserting the error namesrunning.TestClient_ListInstances_StateAll(Substrate-backed) — launches a running instance and a terminated one, then asserts: the no-flag default excludes the terminated instance;--state alland--state anyboth include it (the actual regression — pre-fix this assertion fails because both aliases returned zero instances);--state boguserrors.Tier 0 (
test/e2e/tier0_list_state_test.go, Substrate emulator):TestTier0_ListStateAll_ReturnsRunningAndTerminated— the primary regression: one running + one terminated instance,--state all/--state anymust return both.TestTier0_ListNoFlag_ExcludesTerminated— confirms the no-flag default is unchanged (still excludes terminated).TestTier0_ListStateBogus_ErrorsNotEmpty— the most important negative case. It explicitly assertsstdoutis not"[]"on a non-zero exit — not just "some error occurred" — because a bug where"all"silently degraded to some other wrong-but-plausible filter would still pass a weaker "valid JSON" check. This is exactly the spawn list --state all silently returns nothing — "all" is passed through as a literal instance-state-name filter #527 failure mode.TestTier0_ListStateWrongCase_Errors/TestTier0_ListStateTypo_Errors—ALLandruningeach error rather than silently returning nothing.Fails-before/passes-after verification: both the filter-building
switchinlistInstancesInRegionandvalidateStateFilterwere temporarily reverted to the pre-fix behavior (literal passthrough, no validation). Against that reverted code:TestClient_ListInstances_StateAllandTestValidateStateFilterfail with the exact expected symptom (aliases return 0 instances instead of 2; bogus/wrong-case/typo values returnnilerror), and 4 of the 5 new Tier 0 tests fail (TestTier0_ListNoFlag_ExcludesTerminatedcorrectly still passes, since the default path is untouched by the bug). Restoring the fix turns all of them green.make checkis clean and the full Tier 0 e2e suite passes (232s).CHANGELOG
Added a
### Fixedentry under## [Unreleased]describing the user-visible behavior change and referencing #527.