Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/cli/commands/status/__tests__/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,20 @@ describe('handleProjectStatus — live enrichment', () => {
expect(evalEntry!.deploymentState).toBe('local-only');
expect(mockGetEvaluator).not.toHaveBeenCalled();
});

it('returns empty targetName when no targets are configured (regression for #985)', async () => {
const ctx = makeContext({
awsTargets: [] as unknown as StatusContext['awsTargets'],
deployedState: {
targets: {},
} as unknown as StatusContext['deployedState'],
});

const result = await handleProjectStatus(ctx);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

expect(result.success).toBe(true);
expect(result.targetName).toBe('');
});
});

describe('buildRuntimeInvocationUrl', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/cli/commands/status/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@

render(
<Text>
AgentCore Status - {result.runtimeId} (target: {result.targetName})
AgentCore Status - {result.runtimeId} (target:{' '}
{result.targetName && result.targetName.length > 0 ? result.targetName : 'No target configured'})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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.
  2. Drop this render change entirely since the state is unreachable, and just keep the regression test on handleProjectStatus.
  3. If you want the guard to mean something today, tighten RuntimeLookupResult.targetName from string | undefined to string (since the success path always provides it) — that removes the need for this check and makes the contract explicit.

{runtimeStatus ? ` - ${runtimeStatus}` : ''}
</Text>
);
Expand Down Expand Up @@ -299,7 +300,7 @@
});
};

function ResourceEntry({ entry, showRuntime }: { entry: ResourceStatusEntry; showRuntime?: boolean }) {

Check warning on line 303 in src/cli/commands/status/command.tsx

View workflow job for this annotation

GitHub Actions / lint

Fast refresh only works when a file only exports components. Move your component(s) to a separate file. If all exports are HOCs, add them to the `extraHOCs` option
return (
<Text>
{' '}
Expand Down
Loading