fix(status): exit non-zero on invalid --type/--state filter#1650
Draft
aidandaly24 wants to merge 2 commits into
Draft
fix(status): exit non-zero on invalid --type/--state filter#1650aidandaly24 wants to merge 2 commits into
aidandaly24 wants to merge 2 commits into
Conversation
The status command's --type and --state validation branches rendered an error then bare-returned without setting a non-zero exit code, so scripts and CI under set -e could not detect a rejected filter (silent success on failure). Set process.exitCode = 1 on both branches before returning, which still lets cli.ts's finally cleanup run. Adds command.test.ts asserting exit code 1 for invalid --type and --state, and unset for a valid filter. Fixes aws#984
Contributor
Package TarballHow to installgh release download pr-1650-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.21.0.tgz |
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
agentcore-cli-automation
approved these changes
Jun 26, 2026
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
LGTM. Small, focused fix.
- Using
process.exitCode = 1instead ofprocess.exit(1)is the right call here — it lets thefinallyblock insrc/cli/cli.tsrunTelemetryClientAccessor.shutdown()so the validation-failure telemetry event actually gets flushed before the process exits. - The new tests cover both validation branches and assert the happy path doesn't accidentally set a non-zero exit code. The mocking is at reasonable boundaries (ink
render, the action module, the telemetry wrapper) and matches the pattern already used inexec/__tests__/command.test.ts. - Telemetry is already instrumented on the validation branches via
withCommandRunTelemetrywith aValidationErroroutcome, so nothing missing there.
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
agentcore-cli-automation
approved these changes
Jun 26, 2026
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Reviewed independently — looks good to merge.
Verified the key points already raised in the existing review:
process.exitCode = 1is the right choice:main()insrc/cli/cli.tswrapsprogram.parseAsyncin atry/finallythat callsTelemetryClientAccessor.shutdown(), so theValidationErrortelemetry event recorded bywithCommandRunTelemetrywill flush before the process exits. A hardprocess.exit(1)here would skip that.- Both validation branches (invalid
--typeand invalid--state) get the fix and the new unit tests cover both, plus a happy-path assertion that exit code stays unset. - Mocks in the new
command.test.tsare at sensible boundaries (ink,./action,telemetry/cli-command-run,tui/guards) and mirror the pattern inexec/__tests__/command.test.ts. - Telemetry is already instrumented on these branches (no missing instrumentation).
- The integ-test updates correctly tighten the assertion from
exitCode === 0toexitCode === 1while leaving the failure-telemetry assertions intact.
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.
Description
#984 — status --type with invalid type prints error but exits 0
status with an invalid --type/--state prints an error but returns exit code 0, so scripts and CI cannot detect the rejected filter.
Fix
Set a non-zero exit code on both validation branches. Merge PR #1603 (process.exitCode = 1 before return, adds command.test.ts) — cleaner than a hard process.exit(1) because it lets cli.ts's finally cleanup run. Close PR #1169 (duplicate, uses process.exit(1), diff is stale against pre-#1317 file and will conflict).
This fix was produced by an automated triage+fix run and validated locally (build + unit suite + symptom reproduction). It is being opened as a draft for CI and human review.
Related Issue
Closes #984
Documentation PR
N/A — bug fix; no devguide change required.
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshots — N/A, nosrc/assets/changesChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.