fix(payments): self-heal empty aws-targets.json before T02 deploy#1672
Closed
fahadfa-aws wants to merge 1 commit into
Closed
fix(payments): self-heal empty aws-targets.json before T02 deploy#1672fahadfa-aws wants to merge 1 commit into
fahadfa-aws wants to merge 1 commit into
Conversation
Some agentcore CLI versions scaffold <project>/agentcore/aws-targets.json as an empty list, which makes `agentcore deploy` exit with `Target "default" not found in aws-targets.json` before the CDK synth. Detect that shape in deploy_payment_agent.py and append a `default` target with the account/region the script already resolved. Other entries are preserved, malformed or unexpected shapes are skipped so the user sees the underlying CLI error instead of a silent overwrite. This trades a CLI-version pin in the README (which would go stale the next time @aws/agentcore ships a new version) for a property-based check that keeps working across versions: as long as the failure shape is "no default target in the list", the script self-heals. - deploy_payment_agent.py: add the probe between scaffold and deploy. - README.md: troubleshooting entry covering the symptom and the manual fix for users running `agentcore deploy` directly.
Author
|
@mvangara10 — flagging this for your review when you have a moment. Tagged across the full set of payments-tutorial fixes I've been pushing today; happy to walk through any of them. Audit logs and test evidence are referenced in the PR description. |
Author
|
Superseded by #1738 (consolidated PR) |
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.
Issue
The
@aws/agentcoreCLI scaffolds<project>/agentcore/aws-targets.jsonas an empty list.agentcore deploythen exits withTarget "default" not found in aws-targets.jsonbefore the CDK synth runs, and the user sees a confusing error with no clear next step.Live-reproduced today on both 0.14.0 and 0.19.0 (current
latest). The scaffold writes[]regardless of CLI version, so a fresh user following Tutorial 02 cannot deploy without intervention.A version pin in the README would not help here — the behavior is consistent across the versions a fresh user is likely to install. This PR uses a property-based check instead: if the file exists but doesn't contain a
defaulttarget, append one using the account/region the script has already resolved.Changes
deploy_payment_agent.py: between scaffolding (agentcore create) and deploy (agentcore deploy), checkaws-targets.jsonand append adefaultentry if missing. Existing entries are preserved. Malformed JSON, unexpected shapes (top-level dict, garbage list entries), and missing files are all left alone so the user sees the underlying CLI error rather than a silent overwrite.README.md: troubleshooting entry covering the symptom and a one-line manual fix for users runningagentcore deploydirectly without the script.Verification
Static — tested the probe in isolation against 8 input shapes:
[](the actual scaffold output)default[{name: default, ...}][{name: prod, ...}]default, preserveprod[1, 2, "x"]{...}instead of listAll 8 pass. The inserted code in
deploy_payment_agent.pyis byte-equivalent to the standalone-tested function.Live AWS — ran end-to-end against
us-west-2on both CLI versions:0.14.0[]Target "default" not found in aws-targets.jsonAgentCore-PaymentAgent-defaultreachesCREATE_COMPLETE0.19.0[]Both stacks were torn down after validation. Variables
account_id(line 51) andREGION(line 52) are already in scope at the insertion point.jsonandosare already imported. The probe is positioned after the existingif not os.path.exists(project_dir)skip so the directory is guaranteed to exist.