You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicating a slot in the builder fails when the slot has a value in a Number field #512
On the Build tab, choosing Duplicate on a slot that has a number in a Number field (a "Qty" column, say) adds nothing. The status rail shows "qty" must be a number.
The builder keeps every slot value as a string (toBuildRow → toStringValues in src/components/build-shared/useBuildState.ts). duplicateRow copies those strings, and addRow POSTs them to /api/signups/[id]/slots unchanged. So 12 goes up as "12". Nothing on the server converts it: SlotValuesSchema is z.record(z.string(), z.unknown()), and validateOneValue in src/services/slot-fields.ts requires typeof value === 'number'.
The comment in duplicateRow says "addRow re-serializes for the API", but it doesn't. Its sibling saveRowValues, which cell edits use, does convert number fields with Number(...) and drops empty ones. That's why editing a number works and duplicating doesn't.
An empty Number cell turns into '', which the server reads as missing. So Duplicate only fails when the source slot has a number in it, and then it fails every time.
The same gap is in handleAddSlot (src/components/build-wysiwyg/BuildWysiwyg.tsx), which seeds the group field's value as a string. The builder's group picker only offers date, enum and text fields, so the builder can't reach it today. A group-by set over the API could.
Fix, in outline
Move the number conversion out of saveRowValues into a small helper (e.g. toTypedValues(fields, values)).
Call it from saveRowValues and from addRow before the POST, so Duplicate, Add slot and anything else that goes through addRow send typed values.
Fix the misleading comment in duplicateRow.
Watch for
The existing duplicateRow tests in useBuildState.test.ts assert the uncoerced body, with text values only. Update them, don't just add alongside.
Found by the pipeline's bugs scout in the builder (src/components/build-shared, build-wysiwyg), at 82a180f. Checked by a hook test capturing the POST body plus a DB test calling addSlot with { qty: "12" } (refused) and { qty: 12 } (accepted). https://claude.ai/code/session_014HtUS4AnW9zrtSroCVsxmB
Activity