Repository navigation
fix(customers): include error field on POST 400s - #1128
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@greptile review |
|
|
Reviewed the implementation against the existing customer API contract. The fix looks correct. Adding One optional improvement: add a permanent regression test for the updated 500 response, which is currently covered by recorded live validation but not the committed tests. No blocking changes requested. Ready to merge once the required CI checks pass. |
65add4d to
8816afa
Compare
Intent
Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1093 ("POST /api/customers validation errors omit standard error field"): in
main/routes/customers.ts, include the standarderrorfield alongsidemessageinPOST /api/customerserror responses so callers inspecting eithererrorormessagereceive a consistent payload. Deliver via theno-mistakespipeline as its own PR withFixes #1093in the PR summary.What Changed
errorfield alongsidemessageinPOST /api/customers400 (missing name, invalid phone), 409 (duplicate phone), and 500 error responses inmain/routes/customers.ts.tests/diagnostics-feature-coverage.test.tsverifying that botherrorandmessagefields are returned for duplicate phone, empty name, and invalid phone responses onPOST /api/customers.Fixes #1093
Risk Assessment
✅ Low: Surgical change adding the standard
errorfield alongsidemessageinPOST /api/customerserror responses, backed by HTTP integration test assertions.Testing
Ran the diagnostics feature coverage and customer auth regression suites and drove a live Express API server against an isolated SQLite database for blank name (400), invalid phone (400), duplicate phone (409), and database write failure (500) on POST /api/customers, recording the HTTP response payloads to post-customers-error-responses.json; no visual screenshot was captured because this change is backend API-only with no UI surface change, and all checks passed.
Evidence: POST /api/customers live HTTP error response payloads
{ "scenario_1_empty_name": { "status": 400, "body": { "error": "Name is required", "message": "Name is required" } }, "scenario_2_invalid_phone": { "status": 400, "body": { "error": "Phone number is not valid. Use international format (e.g. +919876543210).", "message": "Phone number is not valid. Use international format (e.g. +919876543210)." } }, "scenario_3_duplicate_phone": { "initial_create_status": 201, "duplicate_status": 409, "duplicate_body": { "error": "Customer with this phone already exists", "message": "Customer with this phone already exists" } }, "scenario_4_database_failure_500": { "status": 500, "body": { "error": "Failed to create customer", "message": "Failed to create customer" } } }Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
node tests/run-electron-node-test.cjs tests/diagnostics-feature-coverage.test.tsnpm run test:customer-authELECTRON_RUN_AS_NODE=1 ./node_modules/.bin/electron -r ts-node/register/transpile-only -e '<live POST /api/customers scenario runner>'✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.