Skip to content

fix(project): deploy payments through the published AgentCorePayments construct - #2186

Open
aidandaly24 wants to merge 7 commits into
refactorfrom
feat/payments-alpha51-adapter
Open

fix(project): deploy payments through the published AgentCorePayments construct#2186
aidandaly24 wants to merge 7 commits into
refactorfrom
feat/payments-alpha51-adapter

Conversation

@aidandaly24

@aidandaly24 aidandaly24 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What

Retires the Payment orchestration the generated CDK app has been carrying, and makes project deploy print a Quick Create connector's authorization URL while the service makes one available.

Why

#2146 restored a pre-Quick-Create adapter into the generated app to unblock scaffolding while AgentCorePayments was unpublished. That construct now ships in @aws/agentcore-cdk@0.1.0-alpha.51, so the vendored loops are obsolete. While they remain:

  • bin/cdk.ts requires every connector to resolve a credentialName to a deployed ARN. A Quick Create connector deliberately has neither, so synthesis throws before constructing the stack.
  • cdk-stack.ts concatenates underscore-stripped manager and connector names into construct IDs, allowing distinct names to collide.

Quick Create is also a two-phase operation: deployment creates the connector, then someone must follow its short-lived authorization URL. A successful deploy that does not print that URL leaves the connector unusable.

How

bin/cdk.ts passes the raw spec and target credentials through to AgentCorePayments. The published construct owns connector variant mapping, credential resolution, runtime wiring, IAM, and outputs instead of the frozen generated scaffold.

After a successful deploy, the CLI:

  1. Lists the resources in that project's CloudFormation stack.
  2. Reads the manager and connector IDs from each Payment Connector physical ARN.
  3. Calls GetPaymentConnector.
  4. Prints authorizationUrl when the response contains one.

That is the complete post-deploy behavior. It does not implement connector status reporting or recovery guidance. A project without Quick Create connectors performs no additional reads, and a read failure never turns a completed deployment into a failure.

Verification

Verified the service contract directly against account 603141041947 in us-east-1:

  • Created a disposable CoinbaseCDP Quick Create connector.
  • CreatePaymentConnector returned PENDING_AUTHENTICATION with an authorization URL.
  • A separate GetPaymentConnector returned the same status and URL.
  • An existing READY connector returned no authorization URL.
  • Deleted the disposable connector and confirmed it was gone.

Code validation:

  • Focused backend and authorization URL tests: 43 passed
  • Generated CDK tests: 2 passed
  • bun run lint
  • bun run format:check
  • bun run build

The earlier full lifecycle verification still covers:

  • Quick Create authoring, synthesis, deployment, and authorization to READY
  • Manual credential provisioning and connector deployment to READY
  • Idempotent redeploy
  • Connector removal preserving reusable credentials
  • remove all deleting the stack, manager, connector, and credential provider

Follow-ups

  • aws/agentcore-l3-cdk-constructs#348 is merged but unreleased. It removes ephemeral AuthorizationUrl and ConnectorStatus stack outputs that can break later stack updates. This PR still pins alpha.51; the pin moves to alpha.52 once published. The CLI requires no behavioral change because it reads the URL from GetPaymentConnector.
  • The released CLI's separate vendored Payment implementation emits the same ephemeral outputs and needs the equivalent removal.

@github-actions github-actions Bot added the size/l PR size: L label Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Sep 3, 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 Sep 3, 2026
@codecov-commenter

codecov-commenter commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.14%. Comparing base (2e30e1f) to head (1bf77c6).
⚠️ Report is 23 commits behind head on refactor.

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2186   +/-   ##
=========================================
  Coverage     97.13%   97.14%           
=========================================
  Files           541      542    +1     
  Lines         37618    37700   +82     
=========================================
+ Hits          36542    36624   +82     
  Misses         1076     1076           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Sep 3, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AgentCore Harness Review

Verdict: Looks good

Deleting the vendored payment orchestration in favor of the published AgentCorePayments construct is the right call — it fixes the Quick Create synth throw in bin/cdk.ts (which required every connector to resolve a credentialName) and the id-collision bug in cdk-stack.ts, and it moves future Payment changes onto a dependency bump rather than a scaffold regeneration.

Things I checked and liked:

  • The new paymentConnectors.ts reporter never fails the deploy: try/catch around listStackManagerIds and around each per-manager reportManager call downgrade errors to a "could not be retrieved" step. The tests cover both branches (top-level and per-manager failure).
  • PaymentConnectorCalls is a clean SDK-boundary seam. The unit tests use an in-memory fakeAccount rather than mocking the AWS SDK, which matches the project's testing guidance.
  • paymentManagerId correctly strips the manager id out of the CFN-reported ARN and passes a bare id through, so it stays working if CFN ever changes what it reports.
  • The reporter is invoked only after updateTargetState on the successful-deploy path (teardown returns earlier), and skips all AWS calls when the spec declares no Quick Create connectors, so projects without Payments pay nothing.
  • AgentCorePayments@0.1.0-alpha.51's exported AgentCorePaymentsProps matches what cdk-stack.ts passes (spec, credentials, agentCoreApplication).
  • Restored tests cover the credentialName-less Quick Create synth path, the manual/Quick Create mix, and the id-collision cases (foo_bar/foobar, A/BC vs AB/C) that motivated the fix.

No changes requested.

… construct

The generated CDK app has been carrying its own Payment orchestration since
#2146 restored a pre-Quick-Create adapter to unblock scaffolding while
AgentCorePayments was unpublished. That construct now ships in
@aws/agentcore-cdk 0.1.0-alpha.51, so the vendored loops are obsolete.

Quick Create is broken on refactor today: bin/cdk.ts requires every connector
to resolve a credentialName to a deployed ARN, and a Quick Create connector
deliberately has neither, so it throws before synthesis. The restored adapter
also concatenates underscore-stripped manager and connector names into
construct IDs, so foo_bar/foobar and A/BC versus AB/C collide, and the tests
covering both behaviors were deleted alongside it.

bin/cdk.ts now passes the raw spec and the target's deployed credentials
straight through, and cdk-stack.ts hands them to AgentCorePayments, which owns
connector variant mapping, credential resolution, runtime wiring and outputs
inside the upgradeable package. Payment orchestration leaves the frozen
scaffold, so future Payment changes reach existing projects through a
dependency bump rather than a regenerated app.

The generated-CDK tests for manual and Quick Create synthesis and for
collision-safe identities are restored.
A Quick Create connector is deployed but unusable until someone follows its
authorization link, and deploy said nothing about it. The link had to be dug out
of the stack's CloudFormation outputs to be found at all, and it expires about
ten minutes after the connector is created, so by the time anyone thought to
look the window was usually gone. The project reported a successful deploy
either way.

Deploy now names each Quick Create connector the spec declares, with its live
status and, while one exists, the link and how long it lasts. An expired
connector says how to get a new link, which is to recreate it: neither
UpdatePaymentConnector nor redeploying an unchanged connector mints another one.

The status and the link are read from the Payments service rather than the
outputs of the same name. Those outputs are Fn::GetAtt values resolved when the
connector was created, so they keep serving a dead link and a stale
PENDING_AUTHENTICATION long after the service has moved on to
AUTHENTICATION_EXPIRED.

Managers are found by their CloudFormation resource type in the project's own
stack. Manager names are account-scoped, so matching the spec against the
account would confuse two projects that both declare `payments`, and reading the
L3's output keys would tie the CLI to names the L3 owns. Connectors then come
from the manager, so connector names cannot collide across managers.

Reads run after the stack is up and never fail the deploy: a status that cannot
be retrieved is reported as such. A project without Quick Create connectors
makes no calls at all.
The authorization report asked the Payments service about a manager using the
physical resource id CloudFormation gives for it, which is the manager's ARN.
`paymentManagerId` accepts only the bare identifier and rejects an ARN against
its own pattern, so every deploy of a project with a Quick Create connector
reported that the connector's status could not be retrieved instead of handing
over its authorization link.

Only reachable against CloudFormation, so the unit tests could not see it: they
fake the service boundary, and the boundary was the defect.
…utput

The generated app does not read this output, and neither does the CLI: the
authorization URL is read from the Payments service because it expires. The L3
is removing the output for that reason, since an output holding an attribute
that disappears fails every later stack update.

Asserting it here only pins a value nothing consumes to whichever L3 version is
pinned, so the pin bump can stand alone.
@aidandaly24
aidandaly24 force-pushed the feat/payments-alpha51-adapter branch from 921232d to 94ea166 Compare September 3, 2026 18:31
@aidandaly24

Copy link
Copy Markdown
Contributor Author

Rebased onto 2e30e1f2.

The typecheck job fails on this base for a reason outside this PR: refactor's tip does not typecheck on its own.

src/handlers/project/buildDeploy.screen.test.tsx(40,9): error TS2741:
  Property 'resolveProjectResources' is missing in type '{ build(); deploy(); resolveDeployedResources(); }'
  but required in type 'ProjectBackend'.

11fb8b5d added resolveProjectResources to ProjectBackend, and #2172's new buildDeploy.screen.test.tsx stub does not implement it. Reproduced in a clean worktree at origin/refactor with none of this branch's code present, and neither implicated file is touched here. It is test-only, so the CLI still builds and deploys.

That is the only typecheck error in the tree. Everything else on this branch is green: lint, format:check, bun test src (2853 passed, 211 files), bun run build, and the generated package's own npm test against the pinned L3.

Verified end to end against a real account since the last push, including the paths that only real AWS can exercise:

  • Quick Create deploy prints the live authorization link and its expiry window
  • completing the provider flow moves the connector to READY
  • an expired connector is reported with recovery guidance, and recovery by recreating the connector mints a fresh link (confirmed: neither UpdatePaymentConnector nor a repeat deploy mints one)
  • manual connector reaches READY through its pre-synth provisioned credential
  • redeploy idempotent; removing a connector preserves its reusable credential; remove all deletes stack, manager, connector and credential provider

@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 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 Sep 3, 2026
The generated app hands the whole spec to AgentCorePayments, which derives every
connector's construct identity. Feeding it colliding names asserted that
derivation, not anything this package decides, and the L3 covers the same
foo_bar/foobar case in its own suite.

Seventy lines of fixture for one resource count, over code owned elsewhere.

The manual and Quick Create synthesis test stays: it is the only check that the
generated app passes the spec and the target's deployed credentials to the
construct at all, which is exactly what regressed when the vendored Payment loops
were restored.
@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 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 Sep 3, 2026
@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 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 Sep 3, 2026
@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Sep 3, 2026
@aidandaly24
aidandaly24 marked this pull request as ready for review September 3, 2026 22:09
const ids = paymentConnectorIds(resource.PhysicalResourceId);
if (!ids) continue;

const connector = await paymentsClient.send(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we catch GetPaymentConnector failures per resource and continue processing?

Currently, one stale or throttled connector lookup stops the entire loop, preventing authorization URLs from being reported for later Quick Create connectors. This can also happen if an unrelated manual connector lookup fails.

Please add a test where the first lookup fails and a subsequent connector still reports its authorization URL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 1bf77c64. The catch now wraps only the individual GetPaymentConnector SDK request, emits a connector-scoped warning on failure, and continues processing later resources. I added the requested regression where the first lookup throws and the second still reports its authorization URL. Focused backend tests pass 43/43; lint, format, and build also pass.

@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 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 Sep 3, 2026
},
"dependencies": {
"@aws/agentcore-cdk": "0.1.0-alpha.45",
"@aws/agentcore-cdk": "0.1.0-alpha.51",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I presume this is the crucial bit. Do we know how these changes will impact existing projects? There's a lot of changes here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants