Skip to content

fix(status): Set a non-zero exit code on both validation branches. Mer... (#984)#28

Draft
aidandaly24 wants to merge 1 commit into
mainfrom
fix/984
Draft

fix(status): Set a non-zero exit code on both validation branches. Mer... (#984)#28
aidandaly24 wants to merge 1 commit into
mainfrom
fix/984

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#984

Issues

Root cause

In src/cli/commands/status/command.tsx the two argument-validation branches (--type lines 93-101, --state lines 104-112) render an error then bare-return without setting a non-zero exit code; withCommandRunTelemetry (cli-command-run.ts:94-136) only records telemetry and never exits, so parseAsync (cli.ts:174) resolves and Node exits 0. The real error paths at command.tsx:131/:165/:416 all call process.exit(1).

The fix

Set a non-zero exit code on both validation branches. Merge PR aws#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 aws#1169 (duplicate, uses process.exit(1), diff is stale against pre-aws#1317 file and will conflict).

Files touched: src/cli/commands/status/command.tsx — invalid --type branch (set exit signal after the render at line 99, before the return at line 100) and invalid --state branch (after the render at line 110, before the return at line 111). Test: src/cli/commands/status/tests/command.test.ts (new, per PR aws#1603).

Validation evidence

The fix was verified by reproducing the original symptom and re-running after the change:

Reproduced via built CLI (dist/cli/index.mjs by absolute path) against a minimal scratch project (agentcore/agentcore.json so requireProject passes). BEFORE (fix stashed + rebuilt): agentcore status --type bogus printed red "Invalid resource type 'bogus'. Valid types: ..." but exited 0; --state bogus printed "Invalid state 'bogus'. Valid states: ..." and exited 0 — the CI/set -e symptom. AFTER (fix restored + rebuilt): both invalid filters print the SAME validation error AND exit 1. Confirmed bash -c 'set -e; node CLI status --type bogus; echo SHOULD-NOT-PRINT' aborts (SHOULD-NOT-PRINT not emitted; script exit 1). New test command.test.ts asserts process.exitCode===1 for invalid --type and invalid --state (mockRender called) and process.exitCode undefined for valid --type agent; all 3 pass. Status directory 63/63 green.

Test suite: green.


Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.

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
@github-actions github-actions Bot added size/s PR size: S agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 37.28% 13640 / 36579
🔵 Statements 36.55% 14501 / 39669
🔵 Functions 31.87% 2338 / 7336
🔵 Branches 31.25% 9044 / 28932
Generated in workflow #82 for commit 9dc5c56 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant