Repository navigation
fix(payments): unblock migrated targets with legacy payment providers - #2774
Conversation
Package TarballHow to installgh release download pr-2774-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.0.1.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v1.x #2774 +/- ##
=======================================
Coverage 96.50% 96.50%
=======================================
Files 709 709
Lines 58861 58865 +4
=======================================
+ Hits 56801 56805 +4
Misses 2060 2060 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
I traced the change against v1.x and #2761. The fix is correctly scoped: the guard only ever fired for projects where providerName() and previousProviderName() disagree, which is the migrated case (migratedFrom === "v1", legacy === undefined) — for a raw v0 project both resolve to the bare credential name, so the inner condition was already unreachable. The v1-native path stays guarded and is still covered by the existing "fails before writing when an old payment provider is not recorded for the target" test, so the absent case of the new condition is exercised. The added regression test asserts behavior (old provider untouched, new provider created under a distinct name) rather than restating the implementation, and it fails on base.
Two non-blocking notes:
-
The lost-state protection is now gone for migrated projects, not narrowed (
src/core/project/backends/cdk/credentials.ts:337-343). A migrated project whose target genuinely lost itsdeployed-state.jsonentry now silently createsexample-<target>-wallet-<hash>and orphans the v0 bare provider, where before it got the explicit "restore the entry, or delete that provider if unused" error. That looks like a deliberate trade-off (the provisioner only sees this target'srecordedmap, so existence of the bare provider genuinely can't distinguish the two cases) — if you want the protection back for migrated projects, the data is already at hand insrc/core/project/backends/cdk.ts:277-279, which reads the wholetargetsmap; passing the provider names/ARNs claimed by other targets intoCredentialProvisionInputwould let the guard skip only when the bare provider is demonstrably in use elsewhere. Fine as a follow-up if you'd rather keep this PR minimal. -
previousName !== provideris now dead inside the guard (line 346). WithkeepsV0CredentialNamesexcluded,previousNameis always${project.name}_${targetName}_${credential.name}(underscores) andprovideris always the hashed form (underscores replaced), so the comparison can never be false. It reads as a meaningful case that no longer exists; dropping it (and inlining the underscored name) would make the remaining branch say what it does. Relatedly, the replacement comment explains only the exclusion — a reader of theifno longer learns what the guard protects against; keeping one line of the original "untracked orphan" rationale alongside the new one would help.
Description
Follow up to #2761.
PR 2761's lost-state guard caused an unintended regression in the migration path. The regression blocked a migrated project from deploying a new target if another target already used its v0 payment provider. The new target had no state entry to restore, and deleting the provider would break the existing target.
This PR skips that guard for projects using v0 provider names. Keep it for v1-native projects. Added a regression test for the previously blocked deployment, which confirms behavior is addressed.
Type of Change
Testing
How have you tested the change?
bun testbun run test:e2e, or explained why they are not applicable(CI does not run them for you)
bun run typecheckbun run lint:checkbun run format:checkbun run auditbun run secrets:checkbun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed themby this PR
command.md(the release workflow regenerates it)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.