Repository navigation
Count a blank slot value as no value when converting a draft - #1125
Conversation
magicComposeToTemplate kept its own blank check, which let a string of only spaces through: it was counted as a value that didn't fit, so the create_signup tool refused the whole signup over it, and a blank Number value became 0. It now skips blanks with isBlankSlotValue before coercing, the rule saving, display, grouping and Publish already use. Fixes #1098. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SSSFGD1DFqFGwcSq9v
Tophat: passedSee it: https://claude.ai/artifact/LYE1tZXH5MzU5eALNkKo5S
Not checked: a real AI provider. A local stand-in returned a fixed draft, and the MCP calls used a token from the local OAuth flow. Ran dca236c against 09127b0 locally, Chromium at 1280×900 and 390×844, made-up data. https://claude.ai/code/session_016YZ9SRunCCu6CzuRivdKqj Generated by Claude Code |
richshaw
left a comment
There was a problem hiding this comment.
Review: passed (round 1)
The slot-values loop in magicComposeToTemplate now skips isBlankSlotValue(raw) before coercing and counts every other miss as a failure. The issue's outline and "Done when" are all met: the hand-written blank check is gone (grep "raw !== ''" finds nothing), blank Number values no longer reach Number(), the tests cover all five field types with "" and " " plus a real misfit, and the strict create_signup path has a unit test. Non-blank values that don't coerce (a number in a text field, "tomorrow" as a date) are still counted exactly as before.
Blocking (0)
Optional (0)
Earlier threads: none
Checks: CI green on dca236c (lint-type-test, e2e, CodeQL). Tophat passed on this same SHA.
Waits for the owner because it's UX: what an assistant's create_signup returns and what the Magic Compose warning counts both change. Card: https://claude.ai/artifact/LYE1tZXH5MzU5eALNkKo5S. The code itself carries no other risk.
https://claude.ai/code/session_016YZ9SWY5sJ74qKExtrmu2F
Generated by Claude Code
|
Approved by the owner at https://claude.ai/code/session_016YZ9SVfNPHkNsZgUBaTPSS Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SW9wbz4ipqewrnw7B5
Fixes #1098.
Session: https://claude.ai/code/session_016YZ9SSSFGD1DFqFGwcSq9v
The problem
magicComposeToTemplate(src/lib/magic-compose/to-template.ts) had its own blank check,raw !== undefined && raw !== null && raw !== '', instead ofisBlankSlotValue, the rule the rest of the app uses. A value of only spaces got past it, so:create_signup(strict) refused the whole signup with "some values do not fit their fields", blaming the format''or' ') went throughNumber()and was stored as0, on both pathsThe fix
isBlankSlotValue(raw)before coercing, and counts every other value that doesn't coerce as a failure. One check covers all three effects.coerceValue's own trimming stays, so" Soup "still becomes"Soup"and a non-date is still refused.Tests
to-template.test.ts: a slot of" "and one of""across text, date, time, List and Number fields give no values and no coercion failures (failed onmainwith{ n: 0 }and failures); a real misfit ("tomorrow") beside a blank date is still counted, alone.signups-write.test.ts:create_signupwith one slot's date" "no longer refuses (failed onmainwith the "do not fit" refusal), and handscreateSignupthat slot without a date. It's a unit test with the service mocked, so it covers strictpersistDraftwithout the database.pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test(252 files, 3885 passed, 1 expected fail) andpnpm test:db(47 files, 913 passed): all pass.grep -n "raw !== ''" src/lib/magic-composefinds nothing.Generated by Claude Code