Skip to content

fix(credentials): name payment providers so connectors can reference them - #2739

Open
dfernaro wants to merge 1 commit into
aws:v1.xfrom
dfernaro:fix/v1-payment-credential-arn
Open

dfernaro wants to merge 1 commit into
aws:v1.xfrom
dfernaro:fix/v1-payment-credential-arn

Conversation

@dfernaro

Copy link
Copy Markdown

Description

On v1.x, every credential-backed payment connector fails to deploy, whatever the credential is called. The deploy creates each credential provider under the target-scoped name <project>_<target>_<credential>. Identity accepts that name ([a-zA-Z0-9\-_]+), but PaymentCredentialProviderConfiguration.credentialProviderArn only accepts [a-zA-Z0-9-.]+ after paymentcredentialprovider/. The ARN the synthesized app hands the PaymentConnector therefore always contains underscores, and CloudFormation rejects it.

The only characters both rules accept are letters, digits and -, because Identity names cannot contain .. This PR changes how payment providers are named and leaves everything else as it is:

  • Payment providers are now named <project>-<target>-<credential>, and underscores in the credential name become hyphens (my_wallet in project example, target dev → example-dev-my-wallet). The spec name and its .env.local variables stay the same.
  • API key and OAuth providers keep <project>_<target>_<credential>.
  • v0 projects, and projects migrated from v0, keep the bare credential name, as they do today.
  • Two credentials can't end up with the same name: names that differ only in _ and - derive the same .env.local variables, and the spec already rejects that. The length check (PROVIDER_NAME_MAX_LENGTH) is unchanged, since the name keeps its length.
  • Existing deployments: an earlier deploy may already have created a payment provider under the underscored name, even though its connector failed. orphanedCredentials now reports such a provider when the recorded ARN still points at it, together with the name it was recorded under. The next deploy creates the hyphenated provider, points the stack at it, and deletes the old one by its recorded name after the stack update. This goes through the same path as a credential dropped from the spec. A teardown deletes it the same way.

Related Issue

Closes #2533

Documentation PR

Not applicable: provider names are internal, and the spec, CLI flags and .env.local variables are unchanged.

Type of Change

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

Testing

How have you tested the change?

  • I ran bun test
  • I ran the relevant end-to-end tests with bun run test:e2e, or explained why they are not applicable
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run build
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them

New tests:

  • credentials.test.ts: a payment credential named my_wallet is provisioned as example-dev-my-wallet. Its ARN matches the service's credentialProviderArn pattern, and the old underscored name does not.
  • credentials.test.ts: orphanedCredentials reports payment providers recorded under the underscored name by that name, for declared and dropped credentials alike. It leaves hyphenated providers and v0/migrated bare names alone. The remover deletes by the recorded name.
  • cdk.test.ts: a deploy whose state records the underscored payment provider passes it to the remover after the stack update.

I did not run the e2e suite. It needs a real Coinbase CDP or Stripe/Privy credential to deploy a payment connector.

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
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…them

A payment connector's credentialProviderArn only accepts letters, digits,
'-' and '.' in the provider name, and Identity names do not allow '.'. The
target-scoped name '<project>_<target>_<credential>' always contains
underscores, so no credential-backed payment connector could deploy.

Payment providers are now named '<project>-<target>-<credential>', with the
credential name's underscores written as hyphens. API key and OAuth providers
keep their names, and v0 and migrated projects keep the bare credential name.

A payment provider recorded under the old underscored name is treated as
orphaned and deleted by that name after the stack update that replaces it.

Fixes aws#2533
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.54%. Comparing base (796277b) to head (6c15339).

Additional details and impacted files
@@           Coverage Diff           @@
##             v1.x    #2739   +/-   ##
=======================================
  Coverage   96.54%   96.54%           
=======================================
  Files         706      706           
  Lines       58543    58567   +24     
=======================================
+ Hits        56521    56546   +25     
+ Misses       2022     2021    -1     

☔ 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.

@dfernaro

Copy link
Copy Markdown
Author

@notgitika this is the v1.x port of #2594, which you labeled port-to-v1. On v1 the underscores come from the target-scoped provider name rather than the generated credential name, so the fix is in how payment providers are named (#2533). #2594 is now closed. Could you take a look?

This branch has not been deployed

No deployments
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.

[Refactor] project add credentials payment does not match Connector regex

2 participants