Repository navigation
[2.0] Fixes #36457, #36458: keep CSV import rows and versions - #38192
Conversation
Hand port of #36562 to 2.0; the automatic backport failed on a conflict. A CSV import update now stores the version it replaces, in the same transaction as the update, and gives the imported entity a change description that points at that version. Before, the import bumped the version without storing the previous one, and the next PATCH rewound the version and overwrote the import's. The import page normalizes CRLF and lone CR line breaks outside quoted cells before papaparse reads the file, so a CSV that mixes line endings keeps every row. 2.0 has no storeVersions helper, so the version rows are written inline the way writeBulkVersionHistory does. #36459 is left out: its server side is already on 2.0 through #37002 and its UI part is 2.1-only.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ Approved 🔴 High riskCSV imports now persist prior entity snapshots and reset change descriptions transactionally; mistakes could corrupt version history or later version sequencing. Backport to 2.0 fixing CSV import version history loss (#36458) and dropped rows from mixed CRLF/LF line endings (#36457). Import updates now store the replaced version in the same transaction, and line breaks outside quoted cells are normalized before parsing. No issues found. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #36458
Fixes #36457
Backport of #36562 to
2.0. The automatic backport failed on a conflict (2.1 went in as #36830).2.0has diverged frommainaround version history, so this is a hand port of the two fixes whose bugs exist on2.0.#36458: a CSV import update loses the version it replaces. On
2.0, a CSV import that updates an existing entity bumps its version but never stores the version it replaces. History goes v0.4, v0.2, v0.1, and the next PATCH lowers the version back to 0.3 and overwrites the import's version.PUTkeeps every version.The fix, in
updateManyEntitiesForImport:What differs from
main:2.0has nostoreVersions/VersionRowshelpers and noMaskedFieldsfiltering of history. The version rows are built inline with2.0'sserializeForVersionHistoryandentityExtensionDAO().insertMany, the same waywriteBulkVersionHistorydoes it on2.0.2.0still usesremoveExtensions+storeExtensionson this path (with the custom-property-only delete from Backport #31863 + #32113 to 2.0: keep table constraints and FK edges on recursive CSV import #37244). Loading the originals' PUT fields doesn't change what that deletes:extensionis stored in the entity JSON, sofindByNamealready returned it.#36457: a CSV that mixes CRLF and LF line endings loses rows. Papaparse infers one line separator for the whole file, so rows ending in the minority separator merge into their neighbours. The import page now normalizes line breaks outside quoted cells before parsing (
normalizeCsvLineBreaks).CSVPureUtils.test.tsdoesn't exist on2.0; it's added with only thenormalizeCsvLineBreakstests, sincemain's other tests there cover helpers2.0doesn't have.Not in this backport: #36459 (year-0001 life cycle placeholder). The server side is already on
2.0through #37002 (LifeCycles.withoutPlaceholderTimestamps). The UI part guards the table created-time in the entity header, which only exists from 2.1. The ADR and the lifecycle IT inBaseEntityITgo with it.Type of change:
Tests:
Run locally on this branch:
DatabaseSchemaResourceITon MySQL + Elasticsearch: 85 run, 0 failures, 0 errors, 7 skipped. That includes the newtest_importCsv_updateKeepsVersionHistory, which checks that after an import update the history is v0.4, v0.3, v0.2, v0.1 with v0.3 intact, that an edit in the same session doesn't rewind it, and that a later edit by another user adds v0.5.DatabaseSchemaResourceIT#test_importCsv_updateKeepsVersionHistoryon Postgres + OpenSearch: 1 run, 0 failures.CSVPureUtils.test.tsandBulkEntityImportPage.test.tsx, 41 run, 0 failures, including the new mixed-line-endings upload test.The same change passed on
main(#36562) and2.1(#36830).Checklist:
[2.0] Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code
Address the two explicit repository requirements before merging.
Findings
Summary
This backport preserves the version replaced by a CSV import and keeps rows separate when an uploaded CSV mixes line endings.
Two repository code requirements still need to be addressed.
Reviews (1) · Last reviewed commit: "[2.0] Fixes #36457, #36458: keep CSV imp..." · Reviewed by Greptile