Skip to content

fix(deploy): select the auto-detected target so a fresh project's first deploy isn't scoped to zero stacks#1753

Merged
tejaskash merged 1 commit into
mainfrom
fix/first-deploy-empty-target-selection
Jul 13, 2026
Merged

fix(deploy): select the auto-detected target so a fresh project's first deploy isn't scoped to zero stacks#1753
tejaskash merged 1 commit into
mainfrom
fix/first-deploy-empty-target-selection

Conversation

@jesseturner21

Copy link
Copy Markdown
Contributor

Description

The very first interactive agentcore deploy on a freshly created project failed with:

Error: CDK deploy failed: Stack selection is ambiguous, please choose a specific stack for import [AgentCore-clitest-default]

Root cause: regression from the #1267 fix (#1659). The TUI deploy flow scopes its stack selector to the target picker's selection (PATTERN_MUST_MATCH over selectedTargets), and deliberately treats an empty selection as "deploy nothing" so the deploy-everything bug can't re-latent.

A fresh project has an empty aws-targets.json, so useAwsTargetConfig takes the auto-detect path: it detects the AWS account/region and saves a default target — but unlike the single-pre-configured-target and multi-target-picker paths, it never populated selectedTargetIndices. DeployScreen then passed selectedTargets = [] into the deploy flow, producing a pattern selector with zero patterns, and toolkit-lib threw NoStacksMatched. Second deploys worked (the target file was populated by then), so every first deploy of a new project was broken.

Fix: saveTarget() now also registers and selects the just-saved target, mirroring the existing single-target path:

setAvailableTargets([target]);
setSelectedTargetIndices([0]);

Related Issue

Closes #1752

Documentation PR

N/A — bug fix, no doc changes needed.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Additional verification:

  • Reproduced before the fix: built the tarball with npm run bundle, installed it fresh, ran agentcore create --name clitestagentcore deploy (interactive) — failed with the exact error above.
  • New regression test src/cli/tui/hooks/__tests__/useAwsTargetConfig.test.tsx covering all three configuration paths (fresh-project auto-detect, lone pre-configured target, multi-target picker). The auto-detect case fails on the unfixed code and passes with the fix.
  • Verified after the fix end-to-end: rebuilt the bundle, re-ran create → deploy against a real AWS account — deploy completed successfully (stack CREATE_COMPLETE, harness READY, deployed state persisted). Test stack cleaned up afterwards.
  • All 806 TUI unit tests pass, including the 11 existing All targets are shown even if only 1 was selected #1267 target-scoping regression tests.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings

@jesseturner21
jesseturner21 requested a review from a team July 13, 2026 18:39
@github-actions github-actions Bot added the size/m PR size: M label Jul 13, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jul 13, 2026
@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 Jul 13, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.24.0.tgz

How to install

gh release download pr-1753-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.24.0.tgz

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 39.91% 14809 / 37101
🔵 Statements 39.17% 15782 / 40286
🔵 Functions 33.97% 2522 / 7423
🔵 Branches 33.41% 9863 / 29521
Generated in workflow #4091 for commit 5b3aa63 by the Vitest Coverage Report Action

@tejaskash
tejaskash merged commit eb76343 into main Jul 13, 2026
34 of 35 checks passed
@tejaskash
tejaskash deleted the fix/first-deploy-empty-target-selection branch July 13, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First interactive deploy of a fresh project fails: "Stack selection is ambiguous, please choose a specific stack for import"

2 participants