Skip to content

fix(kyc): declare financial question conditions in the API contract - #4541

Open
joshuakrueger-dfx wants to merge 1 commit into
developfrom
fix/kyc-financial-conditions-contract
Open

fix(kyc): declare financial question conditions in the API contract#4541
joshuakrueger-dfx wants to merge 1 commit into
developfrom
fix/kyc-financial-conditions-contract

Conversation

@joshuakrueger-dfx

Copy link
Copy Markdown
Collaborator

Why

GET /kyc/data/financial/:id returns the questionnaire. Each question can carry conditions, which
say under what earlier answer the question applies at all — FinancialService.getQuestions has
mapped the field through since #2071 (2025-04):

conditions: q.conditions,

KycFinancialQuestion never declared it. The field is therefore invisible in the Swagger contract
and absent from generated clients, so a consumer cannot reproduce which questions are still
outstanding for a given set of answers — it has to submit and find out from the result. That is the
wrong way round: the same completeness logic the backend runs in FinancialService.isComplete
depends entirely on conditions.

What changed

  • KycFinancialCondition (question, response) added, matching the shape in
    financial-questions.ts.
  • conditions?: KycFinancialCondition[] declared on KycFinancialQuestion as
    @ApiPropertyOptional with isArray, so questions without preconditions keep omitting it.

No runtime change. This PR only writes down what the endpoint already sends.

Tests

One new spec, checked in both directions against the production mapping it pins:

Probe Result
conditions: q.conditions removed from getQuestions 1 of 1 fails
Mutation conditions: q.conditionsconditions: [] 1 of 1 fails

financial.service.ts was restored after each probe and verified clean (git diff empty), so the
probes did not leave the mapping altered.

Full gate on the exact revision 1cbf51e5e: lint (empty output), format:check, type-check
and build all exit 0; Test Suites: 340 passed, 340 of 347 total,
Tests: 6206 passed, 174 skipped, 6380 total; coverage gate exit 0.

The spec derives its expectations from getFinancialQuestions instead of naming questions, so it
breaks when the mapping breaks, not when a question is renamed. It asserts up front that the catalog
contains both questions with and without conditions, so it cannot pass vacuously if that ever stops
being true.

Scope

Only kyc-financial-out.dto.ts and its spec. financial.service.ts is untouched — the mapping was
already correct.

getQuestions has returned conditions since #2071, but KycFinancialQuestion
never declared the field. Generated clients therefore do not know about it and
cannot evaluate which questions still apply to a given set of answers before
submitting the questionnaire.

Runtime behaviour is unchanged. The added spec pins the mapping so that the
declaration and what the endpoint actually sends cannot drift apart.
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.

1 participant