Repository navigation
feat(kyc-controller): keep the retry reasons from the vendor step - #11914
georgeweiler wants to merge 7 commits into
Conversation
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>
Co-authored-by: Cursor <cursoragent@cursor.com>
🛑 Files requiring codeowner reviewTo merge this PR, you'll need to get approvals from the following owners. @MetaMask/universal-kyc (6 files)
ℹ️ Files co-owned by
|
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 ?? []) : [], |
There was a problem hiding this comment.
shouldn't reasons already only be set when the status is retry?
There was a problem hiding this comment.
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[]; |
There was a problem hiding this comment.
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 ?? []) : [], |
There was a problem hiding this comment.
seems odd for us to check knownStatus === 'retry' here. We probably need to use reasons for rejection as well?
There was a problem hiding this comment.
I believe we are purposefully not showing any reasons on the rejected screen. But I'm happy to remove this gate.
There was a problem hiding this comment.
right, but this should be an API level concern in that case? I won't block on this
Explanation
kyc-api now adds
retryReasonstoGET /vendors/{vendor}/step: the relay's retry codes, and only while the status isretry. Failure reasons are not on that response.KycService.getStepreturns that list. An older kyc-api that omits the field reads as[].VendorOnboardingControllerstores the codes on the vendor whilestatusisretryand 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/statusis unchanged.References
retryReasonsin a follow-up. This change does not require a client update to keep compiling.Checklist
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.getStepnow parses optionalretryReasonsfromGET /vendors/{vendor}/stepand always returns a string array (defaults to[]when the API omits the field).KycStepInfoincludes the same optional field.VendorOnboardingControllerpersistsretryReasonsonOnboardingVendorStateonly whilestatusisretry, 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.