Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the csv-parse upgrade and shared TSV parser changes.
No open issues 🎉
What changed in this PR
Updates csv-parse to address the security alert tracked in #5113 and adapts the shared TSV parser used by catalog and consent-data builds.
Changes:
- Raises
csv-parseto^7.0.2, with 7.0.3 resolved in the lockfile. - Removes the unused no-
FIELDbranch and uses typed parsing withcolumns: true. - Adds regression tests for header keys, scalar casts, stray quotes, and empty numeric cells.
| File | Description |
|---|---|
package.json |
Requires the patched csv-parse release range. |
package-lock.json |
Locks csv-parse to 7.0.3. |
app/utils/tsvParser.ts |
Updates parser typing, simplifies header handling, and corrects documentation. |
__tests__/utils/tsvParser.test.ts |
Pins TSV parsing behavior with five focused tests. |
Review effort: Balanced
frano-m
left a comment
There was a problem hiding this comment.
Approving. The upgrade, the dead-branch removal and the columns: true switch all check out: both TSVs parse to identical output on 5.6.0 and 7.0.3, and the new test passes on both. A few optional points:
- Optional: CI never runs Jest.
run-checks.ymlruns only format, lint andtsc, so this new test (and the other 24 suites) won't run on pull requests, and a futurecsv-parsemajor still wouldn't be caught by it in CI. Consider a follow-up issue to addnpx jest --maxWorkers=2to thebuildjob. - Optional, at squash time: "
build-anvil-dbleavesgit statusclean" doesn't show anything, because/files/**/out/is gitignored. The sha256 comparison is the real evidence, so consider dropping that phrase from the commit body. - Since the PR says "Part of #5113" rather than closing it, #5113 and #4949 will need closing by hand once alert #434 shows as fixed.
|
|
||
| /** | ||
| * Returns the file contents parsed into a model shaped by FIELD, or as row arrays if FIELD is omitted. | ||
| * Returns the file contents parsed into a model shaped by FIELD. |
There was a problem hiding this comment.
Optional: consider rewording. The keys come from the header row, and FIELD only picks which columns get cast (columns not in FIELD come through uncast). Something like "Returns the rows of a delimited file as objects keyed by header, with values cast by FIELD_TYPE."
| SIZE: "Size", | ||
| }; | ||
|
|
||
| const FIELD_TYPE = { |
There was a problem hiding this comment.
Optional: consider adding an "array" column (e.g. Tags with "a, b,,c" → ["a","b","c"]). The catalog relies on it for DATA_TYPES, DISEASES and STUDY_DESIGNS.
Part of #5113. Closing #4949 happens after the merge.
What changed
package.jsonrequirescsv-parse^7.0.2(it was^5.0.4). The lockfile resolves 7.0.3, the latest 7.x release.app/utils/tsvParser.ts:if (!FIELD)branch and its docstring clause;parseCsv<T>);columns: trueinstead of an identitycolumnsfunction;@returnsline.__tests__/utils/tsvParser.test.tspinsparseContentRows' output on a small inline TSV: header keys,number/boolean/stringcasts, a stray quote under the tab delimiter withrelax_quotes, and an empty number cell.Why
Dependabot alert #434 (GHSA-8cw4-87c7-c6xx) affects
csv-parse5.6.0 and is fixed in 7.0.2. Dependabot's own bump (#4949) failed type-checking. In 6.0,parsegained typed overloads that reject the no-FIELDcall. In 7.0.3, the newcolumnstyping rejects an untyped identity function inside the genericparseContentRows<T>.columns: trueis csv-parse's built-in way to read the header row, so it replaces the function rather than casting around it.Assumptions I made
group_columns_by_name: truetogether with a duplicated__proto__header.parseContentRowsnever sets that option, and it only parses two TSV files committed to the repo.columns: trueproduces the same keys as the removed identity function. Both TSVs parse to byte-identical output on 5.6.0 and 7.0.3, andbuild-anvil-dbregenerates identical catalog JSON.How to verify
npm ls csv-parse. It shows 7.0.3.npm run lint,npx tsc --noEmitin the root and infiles/,npx jest,npm run build-anvil-dbinfiles/andnpm run build-dev:anvil-catalog. Each passes.build-anvil-dbleavesgit statusclean.parseContentRowsonmainand on this branch, and compare the sha256 ofJSON.stringifyof each result. They match:dashboard-source-anvil.tsv(303 rows)08d3d573…anddisease_abbrev_mapping.tsv(388 rows)3d784ead….npx jest __tests__/utils/tsvParser.test.tson this branch, then again afternpm install --no-save csv-parse@5.6.0. All five tests pass both times.Definition of done (from #5113):
package.jsonrequires^7.0.2, and the lockfile resolves 7.0.2 or later → step 1tsvParser.tshas no no-FIELDbranch → difftsc(root andfiles/), Jest, thefiles/catalog build andnext buildpass → step 2parseContentRows' output and passes on 5.6.0 and 7.x → step 4🤖 Generated with Claude Code