Skip to content

feat(kyc-controller): keep the retry reasons from the vendor step - #11914

Open
georgeweiler wants to merge 7 commits into
mainfrom
gw/kyc-retry-reasons
Open

georgeweiler wants to merge 7 commits into
mainfrom
gw/kyc-retry-reasons

Conversation

@georgeweiler

@georgeweiler georgeweiler commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

kyc-api now adds retryReasons to GET /vendors/{vendor}/step: the relay's retry codes, and only while the status is retry. Failure reasons are not on that response.

KycService.getStep returns that list. An older kyc-api that omits the field reads as []. VendorOnboardingController stores the codes on the vendor while status is retry and clears them otherwise. An entry saved before the field existed is missing it until the next write, which fills [], so the state field is optional.

GET /sessions/:id/status is unchanged.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Additive, optional API fields with backward-compatible defaults; no changes to session status or auth paths.

Overview
Surfaces retry reason codes from kyc-api’s vendor step endpoint so clients can explain why onboarding needs another attempt.

KycService.getStep now parses optional retryReasons from GET /vendors/{vendor}/step and always returns a string array (defaults to [] when the API omits the field). KycStepInfo includes the same optional field.

VendorOnboardingController persists retryReasons on OnboardingVendorState only while status is retry, clears them on any other status, and initializes new vendor state with []. Persisted state from before this field gets [] on the next step refresh.

Tests and the package changelog cover the new behavior.

Reviewed by Cursor Bugbot for commit 3b24128. Configure here.

getStep returns the retry codes kyc-api sends, and vendor state stores them only while the status is retry.

Co-authored-by: Cursor <cursoragent@cursor.com>
@georgeweiler
georgeweiler requested review from a team as code owners December 3, 2026 16:37
@georgeweiler
georgeweiler deployed to default-branch December 3, 2026 16:37 — with GitHub Actions Active
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

🛑 Files requiring codeowner review

To merge this PR, you'll need to get approvals from the following owners.

@MetaMask/universal-kyc (6 files)
  • packages/kyc-controller/CHANGELOG.md
  • packages/kyc-controller/src/KycService.test.ts
  • packages/kyc-controller/src/KycService.ts
  • packages/kyc-controller/src/VendorOnboardingController.test.ts
  • packages/kyc-controller/src/VendorOnboardingController.ts
  • packages/kyc-controller/src/VendorOnboardingTypes.ts

ℹ️ Files co-owned by @MetaMask/core-platform

For convenience in maintaining this repo, this team co-owns the following files and thus may approve changes to them.

Note

You do not need to get approval from @MetaMask/core-platform to merge this PR.

(Expand to view list of files)
  • packages/kyc-controller/CHANGELOG.md

georgeweiler and others added 3 commits December 3, 2026 11:09
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
KycService.getStep and the vendor onboarding state carry the retry codes
as `reasons`, matching the kyc-api step response. The changelog entries
are updated to the new name.

Co-authored-by: Cursor <cursoragent@cursor.com>
this.#write(vendor, {
step: info.step,
status: info.status,
reasons: info.status === 'retry' ? (info.reasons ?? []) : [],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't reasons already only be set when the status is retry?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as in why are we checking info.status === 'retry' here?

* Why a retry is required. Empty unless `status` is `retry`. Failure
* reasons are not included. Absent on answers from an older kyc-api.
*/
reasons?: string[];

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.

getStep always fills this with reasons ?? [], and it's the only thing that builds a KycStepInfo, so I think this can be required no? Same for OnboardingVendorState.reasons, since the controller hasn't shipped yet?

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: George Weiler <georgejweiler@gmail.com>
status: toKycStepStatus(status),
status: knownStatus,
sessionId: sessionId ?? null,
reasons: knownStatus === 'retry' ? (reasons ?? []) : [],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems odd for us to check knownStatus === 'retry' here. We probably need to use reasons for rejection as well?

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.

I believe we are purposefully not showing any reasons on the rejected screen. But I'm happy to remove this gate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

right, but this should be an API level concern in that case? I won't block on this

This branch was successfully deployed

1 active (outdated) deployment
default-branch — 3d0c3974 Deployed Dec 3, 2026 by georgeweiler via Determine whether this PR is a release PR #7956
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants