Skip to content

fix(cli): Change command.tsx:213 from `result.targetName ?? 'No tar... (#985)#45

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

fix(cli): Change command.tsx:213 from `result.targetName ?? 'No tar... (#985)#45
aidandaly24 wants to merge 1 commit into
mainfrom
fix/985

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#985

Issues

  • status shows empty '(target: )' when no target is configured aws/agentcore-cli#985 — On a freshly created project with no deployment target configured, agentcore status prints a broken header AgentCore Status (target: ) with an empty value inside the parens, instead of omitting the label or showing a sensible default like "No target configured". Cosmetic, but it looks like a rendering glitch on the very first command a new user runs after agentcore create.

Root cause

Empty-string vs nullish mismatch at command.tsx:213; verified bug is live at HEAD v0.20.2.

The fix

Change command.tsx:213 from result.targetName ?? 'No target configured' back to result.targetName || 'No target configured' (or the explicit targetName && targetName.length > 0 ? ... : 'No target configured' ternary). CRITICAL: the open PR aws#1171 does NOT fix this issue as written — I read its diff via gh pr diff 1171. It only changes command.tsx line ~141, the --runtime-id lookup path (AgentCore Status - {runtimeId} (target: ...)), and adds an action.ts unit test asserting targetName===''. But the aws#985 reproducer runs agentcore status with NO --runtime-id, hitting the DEFAULT path (line 213), which PR aws#1171 leaves untouched at ?? 'No target configured'. Worse, the --runtime-id path aws#1171 does fix is unreachable by the reproducer (a fresh create has no deployed runtime to look up). PR aws#1171 must be extended to also fix line 213, or it will close aws#985 without fixing the reported behavior.

Files touched: src/cli/commands/status/command.tsx:213 (default-path header render — the line the issue reproducer actually hits). Supporting: src/cli/commands/status/action.ts:702 returns targetName: selectedTargetName ?? '' for the no-target case; src/cli/commands/create/action.ts:96 writes empty aws-targets so the no-target case is the default on a fresh project. command.tsx:141 is the only render line PR aws#1171 currently touches and is the latent --runtime-id-path twin of the same bug.

Validation evidence

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

Reproduced the original symptom on the pre-fix render layer and watched it disappear with the fix, exercising the actual default-path header output (not a unit-only test).

BEFORE (stashed the fix, rebuilt with command.tsx:212 = result.targetName ?? 'No target configured'): In a freshly created project (/tmp/acfix-985.iw6Ypv/acfix985, aws-targets.json = [], no deployment), agentcore status (no --runtime-id) rendered header line: AgentCore Status (target: ) — empty parens. grep target: ) matched -> EMPTY PARENS REPRODUCED. Mechanism confirmed: action.ts:697 returns targetName: selectedTargetName ?? '' (empty string for no-target), and ?? does not catch '' so it prints verbatim.

AFTER (fix restored at command.tsx:212-213 = result.targetName && result.targetName.length > 0 ? result.targetName : 'No target configured', rebuilt): Same command in the same fresh project rendered exactly AgentCore Status (target: No target configured). grep for target: ) -> no match (FIXED). JSON path unchanged: agentcore status --json still emits "targetName": "", confirming the fix is render-layer-only and surgical (action.ts behavior untouched). Mirrors the PR aws#1171 length-check pattern already on the --runtime-id twin at command.tsx:140.

Test suite: green.


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

The default-path status header (no --runtime-id) rendered 'AgentCore
Status (target: )' with empty parens on a fresh no-target project,
because action.ts returns targetName: '' and the '??' operator does not
catch the empty string. Replace the nullish-coalesce with an explicit
length check so the empty-string case falls back to 'No target
configured', mirroring the --runtime-id twin already fixed in PR aws#1171.
@github-actions github-actions Bot added the size/xs PR size: XS label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 37.16% 13593 / 36577
🔵 Statements 36.43% 14452 / 39667
🔵 Functions 31.8% 2333 / 7336
🔵 Branches 31.1% 9000 / 28934
Generated in workflow #99 for commit 1794224 by the Vitest Coverage Report Action

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

status shows empty '(target: )' when no target is configured

1 participant