Repository navigation
fix(catalog): preserve CSV round-trip names - #1150
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 |
[Medium impact] Adds reversible CSV encoding for catalog exports to prevent formula injection. Fix tag whitespace preservation before merging so marked product exports round-trip without changing stored tags. Findings
|
…th `oxfmt` to satisfy the changed-file formatting check in `Lint & Build Validation (Linux)` (which also caused `Required Checks Gate` to fail). ### Invariant - Every file changed by the PR must pass `oxfmt --check` (via `scripts/ci/check-changed-format.cjs`). - Checked all changed root files (`main/lib/csv.ts`, `main/routes/menu-csv.ts`, `tests/issue-248-menu-csv.test.ts`, `tests/menu-csv-formula-export.test.ts`); only `tests/menu-csv-formula-export.test.ts` had formatting violations. ### Verification - `npx oxfmt --check -- main/lib/csv.ts main/routes/menu-csv.ts tests/issue-248-menu-csv.test.ts tests/menu-csv-formula-export.test.ts`: passed - `npm run lint`: passed (0 errors) - `npm run build`: passed - `npm run docs:check` & `git diff --check`: passed - `npx ts-node --transpile-only tests/menu-csv-formula-export.test.ts`: passed (21/21) - `npx ts-node --transpile-only tests/issue-248-menu-csv.test.ts`: passed (284/284)
|
@greptileai review |
1 similar comment
|
@greptileai review |
|
@greptileai review |
decodeQuoteV1Field restores the safety prefix (tab/space/newline/CR) before the per-tag trim stripped it again, silently changing stored tags like '\t=1+1' to '=1+1'. Keep tags verbatim in quote-v1 mode so the encoding round-trips reversibly; legacy imports keep trimming.
|
Greptile P1 addressed in cfa4483: in quote-v1 mode the importer no longer trims per-tag whitespace after |
Intent
PR 7 - Make catalog CSV escaping reversible (Fixes #1075)
Branch:
codex/catalog-csv-roundtripTitle:
fix(catalog): preserve CSV round-trip namesLocked product decisions:
Requirements:
flo_csv_encodingwith valuequote-v1to category, product and add-on exports.Acceptance: repeated new export/import preserves names beginning with
=,+,-,@, whitespace before those characters, and genuine apostrophes. Quoted commas/newlines still parse correctly. Existing IDs, categories and add-on associations remain stable.What Changed
flo_csv_encoding=quote-v1to category, product, and add-on CSV exports (main/lib/csv.ts,main/routes/menu-csv.ts), doubling original leading apostrophes before applying spreadsheet formula neutralization so marked exports round-trip losslessly across formula-triggering prefixes, leading whitespace before formula triggers, and literal leading apostrophes.quote-v1rows, reject unsupported non-emptyflo_csv_encodingmarkers as per-row validation errors, and decode unmarked legacy product/add-on fields only when a stable ID matches an existing record whose stored value proves the leading apostrophe came from formula neutralization.tests/issue-248-menu-csv.test.tsandtests/menu-csv-formula-export.test.ts, and documented thequote-v1contract indocs/reference/api.md,docs/reference/daily-sales-export.md, anddocs/reference/product-invariants.md.Risk Assessment
✅ Low: The change cleanly implements reversible quote-v1 catalog CSV encoding, legacy ID-proven decoding, and unsupported marker validation in accordance with all specified requirements and product invariants.
Testing
Ran the focused catalog, reports, and daily-sales CSV integration test suites (
npm run test:issue-248-csv,npm run test:reports-export,npm run test:daily-sales-export), built the backend (npm run build), and stood up an isolated live Flo Local API server (dist/main/server.js) with a fresh SQLite database to drive all six scenarios over HTTP; captured the exported CSV payloads, import responses, and persisted database rows in~/.no-mistakes/evidence/01M4YF3731WE3TCQHWA6M6NJVA/catalog-csv-roundtrip-live-evidence.json(no screenshot or visual artifact was captured because this change only modifies backend CSV serialization/import handlers and documentation with no UI surface changes). All scenarios and checks passed.Evidence: Live catalog CSV round-trip, legacy ambiguity, and validation evidence
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.
npm run test:issue-248-csvnpm run test:reports-exportnpm run test:daily-sales-exportnpm run buildLive HTTP verification against compileddist/main/server.jsexercising/api/auth/login,/api/menu-csv/export/{categories,products,addons},/api/menu-csv/import/{categories,products,addons}, and/api/reports/daily-sales/exportwith evidence written to~/.no-mistakes/evidence/01M4YF3731WE3TCQHWA6M6NJVA/catalog-csv-roundtrip-live-evidence.json✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.