Repository navigation
fix(platform): clear the product fields an edit empties - #4230
Conversation
Edit product sent an emptied description, category, price, currency or stock as undefined. The write adapter dropped those keys, and the update door read an omitted key as "unchanged", so it kept the old values while the dialog showed success and closed. A field that opened with a value and is blank on Save now goes out as null, which the door already clears on. A field that opened blank stays out of the patch, and a price or stock of zero still goes out as zero. The edit form no longer seeds USD into a product without a currency. Before, an untouched blank currency was saved as USD, and a currency someone had cleared reopened as USD and was written back on the next save. The update contract now allows null on the five fields. Create is unchanged. Closes #3615
yannickmonney
left a comment
There was a problem hiding this comment.
Independent review: ACCEPT
Source: PR #4230 / TALE-160 / #3615, exact head 53738010e50c357eeea71ab0933ac6c030f62978, merge base 96d3428e7aef9fbe287944c62a751901c690a639. Head confirmed at start and immediately before posting.
Reviewer: agent #10 a0f9fd03-7af6-4c69-b602-755201d86f89, run 8835f554-eb8e-4bf7-8754-2d231b322e2d, TALE-557. Distinct from implementation agent #6 / run af5f4e7e-c44a-459d-812f-948be0b244e1. GitHub uses the same principal as the PR author, so this is an explicit independent ACCEPT record in a COMMENT review, not an attempted self-approval.
No blocking findings. The fix addresses the actual omission/null mismatch without changing create or backend patch semantics. The form's opening defaults distinguish deliberately emptied fields from initially blank fields; the string representation of zero remains truthy. Removing the USD seed is necessary for a cleared currency to stay cleared after reopening and an unrelated save.
Independently observed evidence
- Existing dialog + new real-wire regression: 15/15 tests passed (2 files). The regression executes the actual dialog, mutation hook, adapter and backendFetch, not a mutation mock.
- Product backend + engagement adapter: 72/72 tests passed (5 files), including route null forwarding and service omission/clearing controls.
- Importers/numeric schema + reviewer-owned PostgreSQL proof: 36/36 tests passed (5 files), including 10 additional persistence cases. 123 targeted tests total, with one worker per invocation.
- The reviewer proof runs the actual dialog → useUpdateProduct → useBackendMutation → adapter → backendFetch, bridges fetch to the actual Hono route and shared domain field schema, executes the actual updateProduct and SERIALIZABLE transaction, then compares a separate GET readback with a fresh SQL SELECT after commit.
- Readback PASS: all five fields cleared together; each cleared separately while the other four retain their values; API omitted fields remain unchanged; fields that opened blank remain omitted and do not wipe a concurrent fill; zero is saved as zero and an opening zero can deliberately be cleared; the committed all-null product reopens blank and remains cleared after a subsequent name-only edit.
- All 11 existing validation messages used by the edit form are nonempty in EN/DE/FR and DE-CH via the existing German fallback. No new UI strings are introduced.
- Changed TypeScript files:
oxfmt --checkclean; scopedoxlint --type-awareexit 0; scopedtsc --noEmitexit 0, including adapter, hook, route/service and relevant consumers. No whole-workspace type check or whole-platform suite.
Proof boundaries and merge gate
The temporary cluster/database tale_557_review, PostgreSQL 15.18, is owned by this review (loopback port 56423, user review557, synthetic product prod-557). It uses a minimal products schema matching the storage types in migration 0014. Auth/session membership, audit/outbox and unused image/blob effects are stubbed; product update logic, validation, transactions and database reads/writes are real. This is an in-process route/database proof, not a browser or full deployed-stack test.
Initial Bun/shared-worktree startup issues, reviewer response-envelope mismatch, a 5-second reviewer-test timeout and missing scoped-config ambient declarations were corrected in the review harness; final runs above pass. Failure logs are retained. No PR source changes were needed.
Not run: browser, E2E, containers, full platform suite, full backend integration/migration suite, production tests or full authentication/audit/realtime paths. Existing #3617 null-price table presentation remains separate; no visual acceptance claim.
At 04:32Z, hosted checks are 2 success / 5 queued, with none rerun or cancelled. ACCEPT is a correctness review, not permission to bypass required CI. The author owns remaining CI repairs; TALE-359 owns subsequent merge/completion reconciliation. No merge, push or card move performed.
Evidence and reproduction source are retained in TALE-557's delivery box: /agent/output/cbd79690-f37a-4f96-a472-715ca0ddb8c9/ (client-tests-node.log, server-tests.log, readback-and-importers.log, reviewer readback test, scoped configs, locale check, lint/format/types logs and CI snapshot).
What changed
When someone emptied a product's description, category, price, currency or stock in Edit product and chose Save, the dialog closed with a success toast but the old values stayed (#3615). The edit submit used the create dialog's omission rule:
x.trim() || undefined, and a blank number becameundefined. The write adapter (entityBody) dropsundefinedkeys. The update door's patch rule (ProductInput) reads an omitted key as "unchanged" andnullas "clear", so the door answeredokand kept every old value. The image's removal already sentnulland worked.product-edit-dialog.tsxis the only behaviour change:Emptied means
null. If a field opened with a value and is blank on Save, it goes out asnull. The door already clears onnull(the card's live control). The rule reads the form's ownformState.defaultValues, which is what the editor opened with.Untouched blank stays omitted. If a field opened blank and is still blank, it stays out of the patch, as before. Sending
nullfor it would turn a no-op into a write that could undo a concurrent edit.Zero is a value. A price or stock of
0still goes out as0.No USD seed. The edit form used to seed
USDinto a product without a currency. That had two effects:USD;USDand was written back on the next save.The form now seeds the stored currency or blank. The field's placeholder still reads
USD, and the table and details still display a missing currency as USD.contract/products.ts: the update args take| nullon the five fields. Their type was the create shape, sonullcould not be sent with types intact. The create dialog and its contract are untouched; #4198's create-dialog work is merged and not involved.Decisions a reviewer may want to challenge
productprop would sendnullfor a field someone else filled in while the dialog was open. The image keeps its existing|| null(the card's control). It still sendsnullfor an image that opened blank. That is a no-op except under a concurrent edit, and I left it out of this change.Out of scope
nullprice as$0.00, and anullstock as an empty cell. A cleared price therefore reads$0.00in the table until Bug: Products with no price are displayed as zero-priced after backend null readback #3617 lands. The edit dialog shows it blank.draft. The status Select has no empty option.parseInt, while the form validates withNumber, so1e3validates as 1000 and saves as 1. This predates the change.How I verified it
Exact head
53738010e, basemain96d3428e7. The branch merges cleanly withmain8a580fcc2.Regression across the failing boundary. The new
product-edit-dialog.wire.test.tsxruns the real dialog,useUpdateProduct,useBackendMutation, theproducts/mutations:updateProductadapter row andbackendFetch. Onlyfetchis answered, so each assertion reads the exact JSON body the door receives. I ran the final test file againstmain's dialog, then restored it.main96d3428{"name":"Audit widget","imageUrl":null,"status":"active"}(the card'sPRODUCT_CLEAR), and the editor still closednull, success toast, closedstockkey missingstock: null, the rest unchangedcurrency: "USD"sent{name, imageUrl: null, status}only0and stock0USDDoor and service legs. These pin existing correct behaviour, so they pass on
maintoo:routes.test.tsposts the exact emitted body toPOST /products/:id.updateProductreceives everynullunchanged.service.test.tsextends the clearing case withstockandprice(the five-field set was missing those two) and holds an omitted stock or price kept.Suites on the exact head.
app/features/products(client project): 18 files, 112 tests passed. This includes the existing edit, CRUD, view and row-action suites.backend/domains/products,app/lib/backend/engagement.test.tsand thesingle-failure-toastanderror-message-descriptionguards (server project): 7 files, 147 tests passed.Gates on the changed files.
oxlint --type-aware: 0 diagnostics.oxfmt --check: clean.tsc --noEmit: exit 0. It covered the changed files plusmutations.ts,engagement.ts,use-backend-mutation.ts,product-view-dialog.tsx,product-row-actions.tsx,routes.tsandservice.ts.bun run lint:manual: ok.integration-scopeguard: passed.Manual layer: one
reference/automation.mdrow, beside the product image row.Not run here: the full platform suite, a whole-workspace
tsc, browser and E2E, andbackend:integration. CI runs those. No local stack either, so there is no PostgreSQL readback from this branch. The card's own control showed the running API clears all five fields on explicitnull, and the backend is unchanged.Closes #3615