fix(kyc): scope the currentStep fallback to the KYC context - #4591
fix(kyc): scope the currentStep fallback to the KYC context#4591Danswar wants to merge 1 commit into
Conversation
processStatus already reports only over the context's steps, but the currentStep fallback was selected before requiredStepNames even existed and never consulted it. A step irrelevant to the flow - an open AddressChange, PhoneChange or PaymentAgreement - could therefore hijack currentStep and send the caller off to something its flow never asked for, while processStatus reported the context as satisfied. Scoped by the CONTEXT set, deliberately not by requiredStepNames: those change steps are not members of requiredKycSteps at all, so filtering by it would drop them from currentStep for every caller and break the change flows. With no context nothing is narrowed, so callers that pass none get a byte-identical response. Only the fallback is scoped. tryContinue passes currentStep undefined, so the fallback is what answers PUT /v2/kyc; the one caller that does pass an explicit step never passes a context, so it is untouched.
|
Closing without merging: the change is harmful as written, and correcting it leaves nothing observable. The regression
Those steps gate the in-context ones: Scoping the fallback hides exactly the step that is blocking progress:
The caller is told it has actionable work and given no step and no session URL, and it cannot self-heal — the open step blocks Why correcting it is not worth mergingThe fix is to narrow only once the context's own steps are settled. That works, but it makes the change unobservable:
The underlying inconsistency is real — The hijack this PR set out to prevent (an open |
Closes item 2 of #4556. Independent of #4559 — no file overlap, no code dependency in either direction.
Problem
KycInfoMapper.toDtoproduces three context-sensitive things, and two of the three already honour the scope:kycSteps[].isRequiredrequiredStepNames.has(s.name)processStatusrequiredStepsbefore computing the verdictcurrentSteprequiredStepNameseven exists, and never consults itSo a step irrelevant to the flow — an open
AddressChange,PhoneChangeorPaymentAgreement— can hijackcurrentStepwhileprocessStatusreports the context as satisfied. The caller is then sent to something its flow never asked for.Change
The fallback obeys the same scope the verdict already does. This is a consistency fix rather than a new policy: the semantics were decided when
contextRequiredStepswas introduced;currentStepwas simply left out.Deliberate constraints
requiredStepNames.AddressChange,PhoneChange,NameChange,PaymentAgreementandAdditionalDocumentsare not members ofrequiredKycStepsat all, so filtering by it would drop them fromcurrentStepfor every caller and break the change flows. There is a regression test for exactly this.contextis an optional,@IsEnum-validated query param, and onlyRealunitBuynarrows anything (RealunitSell/RealunitTransferreturnundefined). A caller that passes no context gets a byte-identical response, so no other client is affected regardless of who they are.tryContinuepassescurrentStepasundefined, so the fallback is what answersPUT /v2/kyc; the one caller that does pass an explicit step (getOrCreateStep) never passes a context, so it is untouched.Verification
FAILEDfallback context-blind, and scoping byrequiredStepNamesinstead of the context set all turn the suite red.OwnerDirectory(out of context) againstResidencePermit(in context) because the step order is the enum order — a later-sorting out-of-context step would have passed either way and proved nothing.kycsubdomain green (113 passed),tsc --noEmitclean, eslint and prettier clean.Note for the client side
With the context satisfied,
processStatusis alreadyCompleted, so the RealUnit client renders its completed screen and never readscurrentStep. Theundefinedcase is only reachable whenprocessStatusisInProgress, which by definition means an in-context step is actionable. Client-side handling of unmappable steps is tracked separately in RealUnitCH/app#613.