fix(status): show 'No target configured' instead of empty '(target: )' in status header#1171
fix(status): show 'No target configured' instead of empty '(target: )' in status header#1171aidandaly24 wants to merge 1 commit intomainfrom
Conversation
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Thanks for the fix. I want to surface one concern before this is merged: the runtime-status render guard may be defending against a state that is not currently reachable, and the regression test doesn't actually cover the code change.
Nothing here is a correctness hazard — the change is safe and the fallback string matches the default path — but it's worth clarifying the contract in code or description so the next reader isn't misled about which bug lives where.
| <Text> | ||
| AgentCore Status - {result.runtimeId} (target: {result.targetName}) | ||
| AgentCore Status - {result.runtimeId} (target:{' '} | ||
| {result.targetName && result.targetName.length > 0 ? result.targetName : 'No target configured'}) |
There was a problem hiding this comment.
handleRuntimeLookup in action.ts returns success: false early (lines 409–414) when awsTargets is empty, and on the success path selectedTargetName = options.targetName ?? targetNames[0]! (line 416) is guaranteed to be a non-empty string because targetNames.length > 0 is required to reach this point. So on the success branch that reaches this render, result.targetName cannot actually be empty or undefined today — this guard is purely defensive against a future refactor of handleRuntimeLookup.
That's not wrong, but it contradicts the PR description, which frames this as fixing "the same latent bug for that code path." There's no latent bug here right now — the reproducer in #985 (agentcore status with no --runtime) lands in the default path at line 157, which was already fixed in #1068.
Options:
- Leave the guard as defense-in-depth but update the PR description (and maybe a code comment here) to say "defensive guard in case
handleRuntimeLookup's contract changes" rather than claiming it fixes a latent bug. - Drop this render change entirely since the state is unreachable, and just keep the regression test on
handleProjectStatus. - If you want the guard to mean something today, tighten
RuntimeLookupResult.targetNamefromstring | undefinedtostring(since the success path always provides it) — that removes the need for this check and makes the contract explicit.
| }); | ||
|
|
||
| const result = await handleProjectStatus(ctx); | ||
|
|
There was a problem hiding this comment.
This test verifies the handleProjectStatus contract (empty targetName when no targets are configured), but the code change in this PR is on the runtime-status path that calls handleRuntimeLookup. So the test doesn't actually exercise the render line you modified.
It's a fine regression guard for the default-path fix that landed in #1068, but if the goal is to lock in the behavior that this PR changes, consider adding a test for handleRuntimeLookup or a rendering test for the runtime-status header — otherwise nothing in the test suite prevents a future regression of line 113–114.
Also, minor: this test is inside describe('handleProjectStatus — live enrichment', ...) but has nothing to do with live enrichment. Consider moving it to a more appropriate describe block (e.g. the existing handleProjectStatus block that covers target resolution).
Coverage Report
|
PR Test Report (updated)5 passed, 0 failed. Cosmetic fix verified: runtime-id render path now has the same "No target configured" fallback as the default status path; deployed happy path still renders "(target: )" normally. |
Description
agentcore statusrendered an empty target label —AgentCore Status (target: )— in the header when the project had no deployment target configured (e.g. a project freshly created with--defaults).The default-path render at
src/cli/commands/status/command.tsx:156already had a|| 'No target configured'fallback (added in #1068), but the runtime-status path at line 116 (agentcore status --runtime <id>) still rendered(target: {result.targetName})with no fallback, leaving the same latent bug for that code path.handleProjectStatus/handleRuntimeLookupinaction.tsreturntargetName: ''when no target is configured, so''was being printed verbatim.This PR:
(target: No target configured)instead of(target: )when no target is configured. Usedresult.targetName && result.targetName.length > 0 ? result.targetName : 'No target configured'becausetargetNameis typed asstring | undefinedonRuntimeLookupResultand??does not catch the empty-string case the bug describes.src/cli/commands/status/__tests__/action.test.tslocking in the contract thathandleProjectStatusreturnstargetName: ''when there are no configured targets — i.e. the value the JSX fallback depends on.No refactor, no changes outside the status command, and no CDK changes (this is a pure CLI presentation bug).
Related Issue
Closes #985
Documentation PR
N/A — no user-facing docs change.
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 snapshotsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.