Repository navigation
fix(platform): send product stock as the number the form accepted - #4251
Conversation
yannickmonney
left a comment
There was a problem hiding this comment.
ACCEPT — independent review of PR #4251
Reviewed exact head 394dcb947f53e8f55db511719ce2b2d448dbadab against origin/main / base bd2275c3f8bc5f928349cc2a38f10134e666eb42, the TALE-161 contract and issue #3616. Reviewer: agent #9 b7c66e31, TALE-582, run 39985569; distinct from implementation agent #4 5f5307c9, run 72f61644. No blocking findings within this review's scope.
Observed evidence
parseProductNumberusesNumber; validation and both create/edit submit sites call that same parser. Exponent stock is accepted by numeric meaning, explicitly permitted by the issue. String form values remain strings, so stock"0"stays truthy at submit and is not mistaken for an empty field.- Exact-head targeted jsdom run: 4 files / 48 tests passed, one worker. Both create and edit submit
1e3as 1000 and2.5e2as 250. Ordinary1000, price12.5and exponent price1.25e1controls pass. Review retains the entered spelling. - The wire suite reads
JSON.parse(init.body)from the actual interceptedfetchcall. The dialogs, product mutation hooks,useBackendMutation, product adapter rows andbackendFetchare real; only the network response and unrelated upload/router/toast dependencies are stubbed. Both POST request bodies carry stock 1000 for1e3and the1000control. This is request serialization proof, not server persistence proof. - Main negative control: retained the head's dialog/wire regression tests and restored the three changed production source files from main. 6 tests failed / 32 passed: create/edit exponent mutation cases fail with 1 or 2, and both
1e3wire cases fail with 1. Decimal stock and price controls stay green. Restored head sources afterward. - Independently composed #4230 at
53738010e50c357eeea71ab0933ac6c030f62978: exactly one conflict hunk, inproduct-edit-dialog.tsxaround stock/price/currency/category. Resolution preserves #4230'sblank(...)semantics and usesparseProductNumberfor stock and price. All other hunks, including the automation register, apply cleanly. Composed targeted jsdom run: 5 files / 53 tests passed, including #4230's real-body clearing, absent-field and zero controls. This is an ephemeral local composition, not a pushed merge. - Manual documentation accurately distinguishes automated client/request proof from the remaining saved-row readback. No backend, schema, locale or visible control change in #4251.
Reproduction and artifacts
Run from services/platform, using /opt/node/bin on PATH and the existing installed Vitest:
../../node_modules/.bin/vitest run --config vitest.review.config.ts \
app/features/products/components/product-create-dialog.test.tsx \
app/features/products/components/product-edit-dialog.test.tsx \
app/features/products/components/product-number.wire.test.tsx \
app/features/products/utils/product-number-schema.test.ts \
--maxWorkers 1 --reporter verboseThe review config imports the repository's unchanged vitest.ui.config.ts and only permits Vite filesystem access to /agent so reused dependency symlinks work in the isolated checkout. The main replay omits the parser test (main does not export the new helper); the composed run additionally includes product-edit-dialog.wire.test.tsx.
Artifacts in the TALE-582 delivery box: head-tests.log, main-regression.log, composition-apply.log, composed-tests.log, composed-edit.diff, pr4230.patch, plan.md and this report.
Unrun proof / handoff
No independent real-browser typing or visual check, full app/stack, HTTP server or PostgreSQL saved-row readback; no broad suite, lint/format/type-check rerun, E2E or CI execution. The unchanged backend accepts the same numeric request value as the established 1000 control, but that is not a claim of independently observed persistence. The manual KNOW-B9 saved-row check remains unrun. No CI wait, rerun or cancellation; no push, merge or card move. Final merge readiness and any additional readback/CI proof remain with TALE-359.
This ACCEPT is an independent agent verdict, not a native task completion decision. It is recorded as a COMMENT review because the repository token uses the same GitHub principal as the author; it does not claim a separate GitHub approver identity or bypass branch protection.
394dcb9 to
f6b0b7e
Compare
f6b0b7e to
e3bdb6a
Compare
The product form judged a stock or price with `Number`, then Create and Save sent it through `parseInt` / `parseFloat`. A number input keeps an exponent as typed, so stock `1e3` passed the Pricing step and Save as 1000 and went out as 1; `2.5e2` went out as 2. `parseProductNumber` in `product-number-schema.ts` is now the one reading of such a value, the one the rule judges and both dialogs send, for stock and price. Price sends what it sent for every value a number input can hold, and the `data.x ? … : undefined` shape of both submits is unchanged. `KNOW-B9` gains the exponent case and its readback. Closes #3616
e3bdb6a to
4ff3ff2
Compare
What changed
A stock of
1e3in a product passed the form as 1000 and was saved as 1 (#3616). The cause is two different parsers:productNumberSchema) judges the string withNumber.parseInt(stock) andparseFloat(price).A number input keeps an exponent as typed. In real Chromium 141, typing
1e3leavesvalue === "1e3"(valueAsNumber1000, valid). So the two readings disagreed:parseInt('1e3')is 1 andparseInt('2.5e2')is 2.One reading.
parseProductNumber(product-number-schema.ts) is now the only parse, for stock and price. The rule judges with it and both dialogs send it. A submit can no longer send a number other than the one the step or Save accepted.The numeric meaning is accepted, not refused. The issue allows either. I accepted it because:
1e3valid with value 1000;1e20is refused as too large, not as "not a number");Review still shows the entry as typed (
1e3), as it does for price.Price behaviour is unchanged.
NumberandparseFloatagree on every value a number input can hold. They disagree only on0x10,0b1and0o7. A browser empties those; the rule passed them by value (16) whileparseFloatsent 0. That gap closes too.Manual layer.
KNOW-B9gains the exponent case and its readback: the row shows1000, never1. Onereference/automation.mdrow names the specs, beside the products price row.Decisions a reviewer may want to challenge
data.x ? parseProductNumber(data.x) : undefined. I chose that over a schema.transform()to numbers, which would makedata.stocka number. fix(platform): clear the product fields an edit empties #4230 (open) rewrites the same edit submit asdata.stock ? … : blank('stock'). With a number there, a stock of0would read as blank and be cleared. With this shape, a trial merge with fix(platform): clear the product fields an edit empties #4230's head53738010ehas one conflict hunk, inproduct-edit-dialog.tsx, andautomation.mdmerges cleanly. The hunk covers four lines (stock,price,currency,category), because fix(platform): clear the product fields an edit empties #4230 also edits the two adjacent lines. The resolution is fix(platform): clear the product fields an edit empties #4230's four lines withparseProductNumberfor stock and price, for exampledata.stock ? parseProductNumber(data.stock) : blank('stock').On that composed tree, 4 files / 43 tests pass with one worker: both PRs' edit and wire suites (#4230's "every emptied optional field as null" included) and the create suite. The new tests assert only the
stockandpricekeys, so #4230's other body changes do not touch them. The file names do not collide either.2. Review shows
1e3, not1000. It shows what the person typed, as it does for price. Showing the normalized number would be a separate UI change.Out of scope
use-file-import.ts). Bug: Quoted multiline CSV imports silently split one product into two zero-price products #3580–Bug: Excel import mistakes blank first-row cells for missing header columns and rejects valid later rows #3582 cover it, as the issue says.How I verified it
Exact head
394dcb947f53e8f55db511719ce2b2d448dbadab, basemainbd2275c3f.Failing tests first. The failing boundary is the args each dialog hands its mutation. The new cases enter the value through a
changeevent, which leaves it the way a browser does.user.typecannot reproduce this bug: user-event turns a typed1e3into1000in a number input (its input events read"1","","1000").mainbd2275c1e3→ Review → Createstock: 1stock: 1000, Review shows1e32.5e2stock: 21e3→ Savestock: 12.5e2→ Savestock: 21000(create, edit)12.5and1.25e1→ 12.5 (create, edit)Real browser. I typed into
<input type="number" min="0">with Playwright's keyboard in Chromium 141 (headless shell):valuevalueAsNumber1e3"1e3"2.5e2"2.5e2"1000"1000"Request leg.
product-number.wire.test.tsxruns the real write path with onlyfetchanswered:useCreateProduct/useUpdateProduct;useBackendMutation;products/mutations:*adapter rows;backendFetch.For
1e3, the body onPOST /api/app/productsandPOST /api/app/products/prod-1carries"stock": 1000, as it does for the control1000.Readback. The door and service are unchanged. With this fix,
1e3sends the samestockas the control1000, and the issue's own HTTP probe confirmed that the control reads back 1000. I ran no local stack, so there is no PostgreSQL readback from this branch. The manual boxKNOW-B9carries the row check.Mutation check (each one reverted afterwards):
parseIntback at both dialog stock sites fails 6 tests: the four dialog exponent cases and both wire exponent cases. The controls stay green.parseProductNumberreading likeparseIntfails 8 tests across the schema and wire suites.Suites on the exact head.
app/features/products(UI config, one worker): 18 files, 127 tests passed.findBylimits. Two were inproduct-create-dialog.pending.test.tsxand two inproduct-edit-dialog.test.tsx. Both files then passed on their own (19/19), and the whole directory passed with one worker.tests/guards/single-failure-toastanderror-message-description(server project): 75 passed.Gates on the changed files.
oxlint --type-aware: no diagnostics.oxfmt --check: clean.tsc --noEmit(TypeScript 6.0.2): exit 0. It covered the changed files plusapp/router.tsx,lib/env.ts,tests/setup-ui.tsand the platform's.d.tsfiles.bun run knip:check: exit 0.bun run lint:manual: ok.check-guide.tsonsuites/knowledge.md: OK..husky/_: conflict markers clean, opengrep 0 findings, commitlint clean.Not run here: the full platform suites, a whole-workspace
tsc, browser and E2E projects, andbackend:integration. CI runs those.Closes #3616