Describe the bug
The very first agentcore deploy (interactive TUI mode) on a freshly created project fails immediately after synth:
[13:41:25] STEP: Publish assets
[13:41:25] [trace] CDK_TOOLKIT_I1001: Starting Synthesis ...
[13:41:25] [debug] CDK_ASSEMBLY_I0150: --app points to a cloud assembly, so we bypass synth
[13:41:25] [info] CDK_TOOLKIT_I1000: ✨ Synthesis time: 0.01s
[13:41:25] Error: CDK deploy failed: Stack selection is ambiguous, please choose a specific stack for import [AgentCore-clitest-default]
[13:41:25] Status: FAILED
Re-running deploy a second time succeeds, which masks the bug.
To reproduce
agentcore create --name clitest
cd clitest && agentcore deploy (interactive, no flags)
Root cause
Regression from the #1267 fix (#1659). The TUI deploy flow now scopes its stack selector to the target picker's selection (useDeployFlow.ts builds a PATTERN_MUST_MATCH selector from selectedTargets), and deliberately treats an empty selection as "deploy nothing".
A fresh project has an empty aws-targets.json, so useAwsTargetConfig takes the auto-detect path: it detects the AWS account/region and writes a default target — but unlike the single-pre-configured-target and multi-target-picker paths, it never populates selectedTargetIndices. DeployScreen then passes selectedTargets = [] into the deploy flow, producing a PATTERN_MUST_MATCH selector with zero patterns, and toolkit-lib throws NoStacksMatched ("Stack selection is ambiguous...").
On the second run aws-targets.json has one entry, so the single-target path selects index 0 and deploy works — every first deploy of a new project is broken.
Describe the bug
The very first
agentcore deploy(interactive TUI mode) on a freshly created project fails immediately after synth:Re-running deploy a second time succeeds, which masks the bug.
To reproduce
agentcore create --name clitestcd clitest && agentcore deploy(interactive, no flags)Root cause
Regression from the #1267 fix (#1659). The TUI deploy flow now scopes its stack selector to the target picker's selection (
useDeployFlow.tsbuilds aPATTERN_MUST_MATCHselector fromselectedTargets), and deliberately treats an empty selection as "deploy nothing".A fresh project has an empty
aws-targets.json, souseAwsTargetConfigtakes the auto-detect path: it detects the AWS account/region and writes adefaulttarget — but unlike the single-pre-configured-target and multi-target-picker paths, it never populatesselectedTargetIndices.DeployScreenthen passesselectedTargets = []into the deploy flow, producing aPATTERN_MUST_MATCHselector with zero patterns, and toolkit-lib throwsNoStacksMatched("Stack selection is ambiguous...").On the second run
aws-targets.jsonhas one entry, so the single-target path selects index 0 and deploy works — every first deploy of a new project is broken.