Skip to content

fix(widget): no registration question ever renders — the CMS renamed all of them #191

Closed

Description

@sydevs-bot

Summary

The registration form renders none of the optional questions, on every event, whatever a manager enabled in the CMS. SahajCloud's registration questions are experience, referral, aspirations, questions; the widget looks for priorExperience, referralSource, healthInfo, accessibility, guests. Zero overlap, so enabledQuestions() always returns [].

The cause is that src/types/payload/payload-types.ts has not been resynced since 2026-08-07 (c2e6e70) — five SahajCloud schema commits ago, one of them a feat(api)!. The guard written to catch exactly this (satisfies Record<RegistrationQuestionName, …> in src/types/event.ts:95) cannot fire, because it compares against that stale local copy.

Approach

  1. pnpm types:cms to resync src/types/payload/payload-types.ts. Expect this to fail the build, and that is the guard working — it is not a silent fix.
  2. Rewrite RegistrationQuestionsSchema (src/types/event.ts:89-95) onto the four current keys. REGISTRATION_QUESTION_NAMES and RegistrationQuestionNameSchema derive from it and need no change.
  3. src/types/event.test.ts:145 asserts RegistrationQuestionNameSchema.parse('aspirations') throws. It pins the wrong contract and must be inverted.
  4. src/mocks/events.ts:156 sets registrationQuestions with the old keys.
  5. public/locales/*/events.json already carries translations for all nine names — the four live ones are present and unreachable. Drop the five dead ones in the same change.

Acceptance criteria

  • src/types/payload/payload-types.ts is byte-identical to SahajCloud main's src/payload-types.ts, modulo scripts/strip-payload-augmentation.mjs
  • RegistrationQuestionsSchema.shape is exactly experience, referral, aspirations, questions
  • An event whose CMS payload enables aspirations renders that question in RegistrationView
  • No locale bundle carries a questions.* key that is not in EVENT_REGISTRATION_QUESTIONS
  • A submitted answer posts under the CMS key, so SahajCloud's additionalProperties: false schema accepts it

Verification checklist

  • pnpm types:cms && pnpm typecheck — passes
  • pnpm test:run — passes, including the inverted event.test.ts assertion
  • Reintroduce the defect at its real site (revert RegistrationQuestionsSchema to the five old keys) and watch a new spec go red before restoring — per docs/testing.md, "A regression spec is not finished until it has FAILED"
  • curl -s "$VITE_SAHAJCLOUD_URL/api/events/<id>?select[registrationQuestions]=true" returns only keys the schema now names

Notes

Filed by the Thursday survey-contracts run, from check 2 (generated type freshness).

Evidence: the full chain, measured

The two contracts, side by side. Event['registrationQuestions'] in each copy of the generated file:

SahajCloud src/payload-types.ts:324 (truth) SahajAtlasWeb src/types/payload/payload-types.ts:321
experience priorExperience
referral referralSource
aspirations healthInfo
questions accessibility
— guests

SahajCloud's is generated from EVENT_REGISTRATION_QUESTIONS (src/lib/registrations/questions.ts:27), which is also the source of the additionalProperties: false JSON schema on Registrations.questions.

How it reaches the screen:

  1. src/config/api/fetch.ts:585 selects registrationQuestions: true — the raw collection field, not a reshaped feed.
  2. src/types/event.ts:199 parses it through RegistrationQuestionsSchema.nullish().
  3. That schema (event.ts:89-95) is a z.object of the five stale keys, all .nullish(). Zod strips unknown keys, so {aspirations: true} parses to {} — no error, every key undefined.
  4. REGISTRATION_QUESTION_NAMES (event.ts:102) is Object.keys(...shape) → the five stale names.
  5. enabledQuestions() (src/views/RegistrationView/RegistrationView.tsx:22-28) filters those names by questions[name] → [].
  6. RegistrationForm.tsx:464 maps over that array → no fields rendered.

RegistrationSchema.questions (src/types/registration.ts:12) is z.record(RegistrationQuestionNameSchema, …), so even a hand-built answer under a live CMS key would be rejected client-side.

Why nothing caught it. The comment above the guard says the key set "can't drift from the backend" and that a resync "fails the build here until the schema (and the form) are updated to match". Both are true — conditional on the resync being run. It has not been run for 27 days, so the guard has been comparing the schema against a copy of itself.

Corroboration that the rename is real and already half-adopted: public/locales/en/events.json under questions carries all nine keys — accessibility, aspirations, experience, guests, healthInfo, priorExperience, questions, referral, referralSource. The four current names were translated; only the type was never resynced, so they are unreachable.

Staleness measured: git log -1 -- src/types/payload/payload-types.ts → c2e6e70, 2026-08-07. SahajCloud commits touching src/payload-types.ts since: 5a4035c (feat(api)! user-messages), 2961a73 (SEO endpoint), 720fd74 (registrant voting), b4d7741 (submissions as diff), 4fbbff8 (event submissions). src/types/payload/response-types.ts is identical to SahajCloud's and is not affected — only the payload-types.ts half of pnpm types:cms is behind.

Not verified: I could not exercise a live registration against a preview, so the user-visible claim is read off the source chain above rather than observed in a browser. Every step in that chain is a cited line.

🤖 Written by the sydevs autonomous loop — see what this is

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    High

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions