Repository navigation
Neutralize spreadsheet formulas in CSV exports - #36070
Conversation
Cells starting with = + - @ tab or CR are prefixed with a quote on export so a spreadsheet shows them as text instead of evaluating them. Import strips the quote again, so an exported file re-imports unchanged.
❌ 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 |
A value such as "'=x" was exported unchanged and then lost its quote on import. Such values now get one more quote on export, so import returns every value exactly. Tests cover quoted dotted FQNs, which are left untouched.
…id raw Recursive database- and drive-service exports re-read the already escaped child export and formatted it again, so nested cells gained a second quote and kept one after re-import. Restore those cells before re-adding them. The Bulk Edit grid loads the export response directly, so it now strips the escape when it loads a CSV and adds it back when it builds the CSV for import, with the same rule as CsvUtil. Records the escaping contract in docs/decisions.
|
| Count | Rule |
|---|---|
| 3 | react-hooks/exhaustive-deps |
| 2 | openmetadata-imports/no-impure-pure-utils |
| 1 | openmetadata-imports/no-cross-page-imports |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage.tsx:143:1 |
openmetadata-imports/no-cross-page-imports |
Page features must not import another page feature. Move shared code to components, hooks, interfaces, or pure utilities. |
| 🟡 | src/pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage.tsx:875:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has an unnecessary dependency: 'entityType'. Either exclude it or remove the dependency array. |
| 🟡 | src/pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage.tsx:1375:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'handleImportWebsocketResponse' and 'handleResetImportJob'. Either include them or remove the dependency array. |
| 🟡 | src/pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage.tsx:1466:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 'filterColumns'. Either include it or remove the dependency array. |
| 🟡 | src/utils/CSV/CSVPureUtils.ts:16:1 |
openmetadata-imports/no-impure-pure-utils |
Pure utilities must not depend on React, UI, state, hooks, pages, or REST clients. Move orchestration/rendering out or move shared types to a lower layer. |
| 🟡 | src/utils/CSV/CSVPureUtils.ts:17:1 |
openmetadata-imports/no-impure-pure-utils |
Pure utilities must not depend on React, UI, state, hooks, pages, or REST clients. Move orchestration/rendering out or move shared types to a lower layer. |
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changedThe import result echoes parsed (unescaped) cells, while the submitted CSV now carries the formula escape, so rows with cells like '- bullet' were never highlighted as failed.
There was a problem hiding this comment.
🟡 Changes recommended
Both async lineage export routes bypass formula neutralization in their shared CSV writer, leaving malicious pipeline descriptions executable as spreadsheet formulas in downloaded CSVs.
1 open issue
What changed in this PR
This PR adds reversible formula escaping to OpenMetadata’s shared CSV export/import flow, protecting spreadsheet users while preserving stored values across round trips.
Changes:
- Prefix formula-like cells on export and remove one escape quote on import.
- Restore nested exports before reformatting and apply the same rule in the Bulk Edit grid.
- Add Java and UI regression coverage and document the CSV contract.
| File | Description |
|---|---|
openmetadata-ui/src/main/resources/ui/src/utils/CSV/CSVPureUtils.ts |
Adds escape/restore helpers and normalizes failed-row matching. |
openmetadata-ui/src/main/resources/ui/src/utils/CSV/CSVPureUtils.test.ts |
Tests formula round trips, grid serialization, and failed-row matching. |
openmetadata-ui/src/main/resources/ui/src/pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage.tsx |
Restores escaped cells when loading the grid. |
openmetadata-service/src/test/java/org/openmetadata/csv/EntityCsvTest.java |
Tests export escaping and both import parsers. |
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DriveServiceRepository.java |
Prevents double escaping in recursive drive exports. |
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DatabaseServiceRepository.java |
Prevents double escaping in recursive database exports. |
openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java |
Restores escaped values in both parse overloads. |
openmetadata-service/src/main/java/org/openmetadata/csv/CsvUtil.java |
Escapes formula-like cells in the shared formatter. |
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DatabaseServiceResourceIT.java |
Tests recursive export escaping and import round trips. |
docs/decisions/2026-10-30-entity-csv-export-escapes-formula-cells-and-import-restores-them.md |
Records the escaping contract and compatibility implications. |
Review effort: Balanced
exportCsvAsync and exportByEntityCountCsvAsync write rows through writeCsvRow, which bypassed CsvUtil.formatCsv, so a pipeline description such as =HYPERLINK(...) reached the downloaded CSV unescaped. Apply CsvUtil.neutralizeFormula to every cell in that shared writer. Lineage CSV is export-only, so no import-side restore is needed.
yan-3005
left a comment
There was a problem hiding this comment.
A couple of other CSV outputs don't go through formatCsv, so they don't get the new escaping:
- Ontology release export (
GET /v1/ontologyReleases/{id}/exportastext/csv):OntologyReleaseExporter→NativeOntologyCsvCodec.write→NativeOntologyCsvWriter.printwrites the label, description and other cells as they are. Running them throughCsvUtil.neutralizeFormulawould cover it;NativeOntologyCsvCodec.readwould then needrestoreFormulaso re-importing an exported file still round-trips. - SPARQL results as CSV (
POST /v1/ontologies/{id}/sparql):OntologySparqlQueryServicehands the result set to Jena'sResultSetFormatter.outputAsCSV, which writes literals raw as well.
The search export already has its own check in SearchResultCsvExporter.escapeCsv, but it doesn't treat a leading tab or CR as a trigger the way CsvUtil now does. Might be worth pointing it at neutralizeFormula so there's one rule.
Happy for these to be a follow-up if you'd rather keep this PR to the entity exports.
|
@yan-3005 Thanks. These are outside what this PR covers (entity CSV exports). On the details: the search export already strips leading whitespace, including tab and CR, before checking, so it's covered. For SPARQL, the API returns the standard results format that clients parse, so any escaping belongs in the console's Download button rather than the API. I'll raise the SPARQL download and the ontology release export as a follow-up. |
|
One more export path this doesn't cover: the sample data download.
|
🚦 Removed from the merge queue —
|
…a-injection # Conflicts: # openmetadata-ui/src/main/resources/ui/src/pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage.tsx # openmetadata-ui/src/main/resources/ui/src/utils/CSV/CSVPureUtils.test.ts
Code Review ✅ Approved 4 closed / 4 findings🔴 High risk · Prefixing formula-like cells across REST CSV exports changes their public values, which could break clients expecting raw stored values. Neutralizes spreadsheet formula cells in CSV exports by prefixing ✅ 4 closed✅ Edge Case: Values that already start with
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
…e-status-dos Resolve LineageRepositoryTest conflict by keeping both the edge-pipeline authz tests and main's CSV-formula export tests (#36638, #36070). The source-file changes auto-merged: main's read-path search-lineage permission filter is complementary to this branch's write-path edge-pipeline authz.




Fixes open-metadata/openmetadata-collate#7803
Summary
Exported CSVs wrote user-controlled cells verbatim, so a value such as
=HYPERLINK(...)in a description was evaluated as a formula when the export was opened in a spreadsheet.Fix: cells starting with
=,+,-,@, tab or CR are prefixed with'on export, in the REST export response itself. Import removes exactly that quote, so export → edit → re-import round-trips unchanged. The rule is recorded indocs/decisions/2026-10-30-entity-csv-export-escapes-formula-cells-and-import-restores-them.md.What changed
CsvUtil.formatCsv(the export path for all entity/lineage exports) escapes formula cells vianeutralizeFormula; bothEntityCsv.parseoverloads reverse it viarestoreFormula.restoreFormula/neutralizeFormulainCSVPureUtils.ts, same rule as the server), so users see stored values.EntityCsvTest(unit),DatabaseServiceResourceIT.test_importExportRecursive_escapesFormulaCellsOnce(nested export + round trip; fails without the fix),CSVPureUtils.test.ts(UI helpers).Details
"local.mysql".default(start with") anduser:x;team:ylists are untouched. Field-level escaping (;,,, quotes) happens before and is reversed after, so it is unaffected.'=x) gets one more quote on export, so every value comes back exactly. Negative numbers and markdown bullets (- item) round-trip too.'''=already quotedand lost data on re-import; the new IT covers that.'-5where the stored value is-5. A hand-written import cell starting with'+ trigger loses that one quote.openmetadata-service(183) green;DatabaseServiceResourceITrecursive import/export ITs (5) green;CSVPureUtils.test.ts(20) andBulkEntityImportPage.test.tsx(37) green. Earlier: dotted-service-name round-trip ITs inDatabaseResourceITgreen.

Confidence Score: 5/5
The PR appears safe to merge; the previous apostrophe-loss issue is fixed.Summary
Protects formula-like CSV cells on export and restores their original values on import.
Reviews (2) · Last reviewed commit: "Keep values already shaped like an escap..." · Reviewed by Greptile
Summary by Gitar
SampleDataTable.utils.tswithFORMULA_LIKEto match entity exportsLineageRepositoryasync exportsDatabaseServiceRepositoryandDriveServiceRepositoryso each cell is escaped onceThis will update automatically on new commits.