Skip to content

chore: rsvpFormFields BE shape migration shim#164

Merged
sharmeebuilds merged 1 commit into
devfrom
chore/rsvp-form-fields-be-shape-migration
May 28, 2026
Merged

chore: rsvpFormFields BE shape migration shim#164
sharmeebuilds merged 1 commit into
devfrom
chore/rsvp-form-fields-be-shape-migration

Conversation

@sharmeebuilds
Copy link
Copy Markdown
Collaborator

Summary

Transitional dual-shape support for rsvpFormFields while ESP BE PR #903 is in flight. PR #903 changes the schema from the legacy { required: string[], visible: string[] } to the new { fields: [...] } — a breaking change. Until #903 ships everywhere and stored data is normalized, EMC must work against both shapes.

Save side (useEventFormSave.ts):

  • Send the new { fields } shape first.
  • On 400 whose validation errors point at rsvpFormFields, retry with the legacy { required, visible } payload.
  • Per-field options overrides are not representable in the legacy shape and are dropped with a console.warn so QA can see the loss.

Read side (eventFormMappers.ts):

  • readRsvpFormFields() adapts either GET shape to the array form the form state expects.
  • Without it, events stored under the legacy shape would open with an empty RSVP fields list in the edit form.

Why stacked on bugfixes/configs

This PR is stacked on PR #162 (bugfixes/configs) which contains the structural fixes that must remain after this migration is reverted (speciallyHandledFields entry, Array.isArray guard, result.error.message extraction). Keeping them in separate PRs means:

After #162 merges to dev, GitHub will auto-retarget this PR to dev.

Cleanup after BE migration

All temporary code is tagged rsvp-shape-migration. Once ESP #903 has shipped to dev/stage/prod and stored events return the new shape on GET, revert this PR — git revert of the merge commit on dev removes everything tagged and nothing else. The cleanup checklist is in the header comment of useEventFormSave.ts.

Test plan

  • Save an event with rsvpFormFields populated against a pre-#903 ESP BE — observe the console.warn and verify the legacy retry succeeds.
  • Save the same event against a post-#903 ESP BE — verify no retry happens (new shape accepted on first try).
  • Open an event previously saved under the legacy shape on a post-#903 BE — verify the RSVP fields list loads correctly (not empty).
  • Open an event saved under the new shape — verify fields load as before.

🤖 Generated with Claude Code

Adds transitional dual-shape support for rsvpFormFields while ESP
BE PR #903 (https://git.corp.adobe.com/wcms/events-service-platform/pull/962/files
sibling: PR #903) is in flight. The BE is moving from the legacy
{ required: string[], visible: string[] } shape to the new
{ fields: [...] } shape — a breaking change. Until #903 ships to
dev/stage/prod and stored events are normalized, EMC must work
against both shapes.

Save side (useEventFormSave.ts):
- isRsvpFormFieldsRejection() detects 400 responses whose validation
  errors point at rsvpFormFields (Ajv errors don't include the field
  name in `message`, so we also walk `errors[].instancePath`).
- toLegacyRsvpFormFieldsPayload() rewrites the new {fields} payload
  to the legacy {required, visible} shape. Per-field `options`
  overrides aren't representable in the legacy shape and are dropped
  with a console.warn so QA can see the loss.
- Update and create branches send the new shape first and retry with
  the legacy payload on rsvpFormFields-flavored 400s.

Read side (eventFormMappers.ts):
- readRsvpFormFields() adapts either GET shape to the array form the
  form state expects. Without it, events stored under the legacy
  shape would open with an empty RSVP fields list.

All temporary code is tagged `rsvp-shape-migration` so the cleanup
after #903 ships is a clean grep-and-delete; the structural fixes
from the prior `fix: rsvp form fields handling` commit are permanent
and must stay (see header comment in useEventFormSave.ts for the
checklist).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sharmeebuilds sharmeebuilds requested a review from qiyundai May 26, 2026 15:33
@sharmeebuilds sharmeebuilds changed the base branch from bugfixes/configs to dev May 26, 2026 15:42
@qiyundai
Copy link
Copy Markdown
Collaborator

Is the revert requirement time sensitive? Or we can rely on this shim to be forward compatible?

@sharmeebuilds
Copy link
Copy Markdown
Collaborator Author

Is the revert requirement time sensitive? Or we can rely on this shim to be forward compatible?

I'd say revert should be done once BE finishes migration. Currently without this fallback the regular event creation flow is failing. Merge this PR only if BE https://git.corp.adobe.com/wcms/events-service-platform/pull/903 is not merged to dev and QA is blocked.

@sharmeebuilds sharmeebuilds merged commit 1ba7e8b into dev May 28, 2026
3 checks passed
@qiyundai qiyundai mentioned this pull request May 29, 2026
5 tasks
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.

2 participants