fix(kyc): report submission completeness for personal and financial data - #4426
fix(kyc): report submission completeness for personal and financial data#4426joshuakrueger-dfx wants to merge 3 commits into
Conversation
The financial and personal data submit endpoints stored incomplete drafts and returned HTTP 200 without advancing the step, leaving clients unable to tell that anything was missing. Both endpoints now return the completeness state and the missing field keys. Also declares the previously undocumented question conditions in the API contract, so clients can determine which questions apply.
…esponse The financial draft path passed an undefined status into KycStep.update, which cleared status and sequenceNumber on the returned entity, so the response omitted two required fields. The personal data endpoint reported entity field names that do not exist in the request contract; they are now mapped to the request field paths, and the mail field is omitted because it cannot be set through this endpoint.
Object.assign copied undefined values, so calling update without a status or sequence number cleared both on the in-memory entity. Callers that only wanted to store a result therefore returned responses without two required fields, and the previous call-site workaround wrote a possibly stale status back to the database. Dropping undefined values at the source keeps the write behaviour unchanged and fixes the file upload path as well.
|
Closing in favour of two narrower changes. Reviewing this branch against 1. The reported symptom is fixed by six lines, not by the DTO extension. 2. That same fix reactivates a branch in 3. The description also claimed the personal-data step is unreachable while Replaced by:
|
Why
A tester reported from the sandbox: "after submitting the financial information the status does not change at all".
Root cause:
updateFinancialDataalways stores the submitted answers (draft behaviour, intended), but only advances the step whenFinancialService.isCompleteis satisfied. On an incomplete submission the client receives HTTP 200 with an unchanged step and no indication that anything is missing — it looks like a successful no-op.The client cannot determine completeness on its own either:
isCompleteevaluates conditional questions viaq.conditions, and whilegetQuestionsdid returnconditionsin the JSON, the field was never declared in the API contract, so generated clients do not know about it.updatePersonalDatahad the same class of defect withuser.isDataComplete.Solution
Both submit endpoints now return
KycStepSubmitDto(additive, extendsKycStepBase):complete: boolean— whether the submission fulfilled the required fields and advanced the stepmissingFields: string[]— which required entries are still missingCompleteness has a single source of truth:
FinancialService.getMissingFieldsis authoritative andisCompletedelegates to it; likewiseUserData.missingKycFieldswithisDataComplete.conditionsis now declared in the Swagger contract.For personal data the missing entries are mapped to the request field paths (
firstname→firstName,location→address.city, …), because the entity names do not exist inKycPersonalData.mailis deliberately excluded — it cannot be set through this endpoint (that is the ContactData step), so reporting it would be unactionable for the client.Scope / non-goals
computeProcessStatusis untouched. That an unsubmitted required step keeps the overall status at "in progress" is verified, intended behaviour.updatePaymentDatauntouched.KycStepBasefields.Behaviour preserved deliberately
The pre-existing
every()short-circuit is retained: once a required answer is missing, option values of later questions are no longer validated. Same input, same throw behaviour as before — otherwise a draft submission containing a stale option value would have started returning 400 instead of 200. Covered in both directions by tests.Tests
105 tests green (from 92). Every new test was verified to fail without its corresponding change, each fix removed individually:
Gates:
npm run lint,npm run format:check,npx tsc --noEmit,npx jest src/subdomains/generic/kyc— all green.Known gaps
@dfx.swiss/reactneeds the two new fields, andDFXswiss/servicesneeds to surface them in the form. The change here is purely additive and breaks no existing client, but the reported sandbox symptom only disappears once a consumer reads them.mailis filtered out of the personal data response as a defensive measure only. It cannot occur in the regular flow:requiredKycStepsordersContactDatabeforePersonalDataandgetNextalways returns the first unfinished step, so the personal data step is unreachable while the mail address is unset.