fix(cli): Change command.tsx:213 from `result.targetName ?? 'No tar... (#985)#45
Draft
aidandaly24 wants to merge 1 commit into
Draft
fix(cli): Change command.tsx:213 from `result.targetName ?? 'No tar... (#985)#45aidandaly24 wants to merge 1 commit into
aidandaly24 wants to merge 1 commit into
Conversation
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.
Coverage Report
|
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.
Refs aws#985
Issues
agentcore statusprints a broken headerAgentCore 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 afteragentcore 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 toresult.targetName || 'No target configured'(or the explicittargetName && targetName.length > 0 ? ... : 'No target configured'ternary). CRITICAL: the open PR aws#1171 does NOT fix this issue as written — I read its diff viagh pr diff 1171. It only changes command.tsx line ~141, the--runtime-idlookup path (AgentCore Status - {runtimeId} (target: ...)), and adds an action.ts unit test asserting targetName===''. But the aws#985 reproducer runsagentcore statuswith 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 freshcreatehas 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:
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. greptarget: )matched -> EMPTY PARENS REPRODUCED. Mechanism confirmed: action.ts:697 returnstargetName: 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 exactlyAgentCore Status (target: No target configured). grep fortarget: )-> no match (FIXED). JSON path unchanged:agentcore status --jsonstill 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.