Skip to content

fix(ingestion): parse npm/pnpm lockfiles natively, drop snyk-nodejs-lockfile-parser#259

Merged
theagenticguy merged 1 commit into
mainfrom
fix/replace-snyk-lockfile-parser
Jun 28, 2026
Merged

fix(ingestion): parse npm/pnpm lockfiles natively, drop snyk-nodejs-lockfile-parser#259
theagenticguy merged 1 commit into
mainfrom
fix/replace-snyk-lockfile-parser

Conversation

@theagenticguy

Copy link
Copy Markdown
Owner

What

npm install -g @opencodehub/cli emitted 5 deprecation warnings. Three (lodash.clone, lodash.isequal, uuid@8) came from snyk-nodejs-lockfile-parser — a ~126-package transitive tree the CLI bundled solely to list resolved packages from a lockfile. This replaces it with a native parser and removes the dependency from both @opencodehub/ingestion and @opencodehub/cli.

Result: warnings drop 5 → 2. (The remaining glob/inflight come from @sourcegraph/scip-python and need an upstream fix — tracked separately.)

Why native parsing is the right call

All the dependency-ingestion phase needs from a lockfile is the flat set of resolved name@version pairs, and every lockfile shape already carries that verbatim:

Lockfile Source of pairs
npm v2/v3 packages map — keyed by node_modules/<name> path + version
npm v1 nested dependencies tree — version per node
pnpm 5/6/9 packages:/snapshots: keys — name@version (or legacy /name/version), peer suffixes stripped

The license harvester in this same file already string-scanned the raw lockfile, so the package list and its licenses now come from one pass over one source of truth. No YAML dependency added — pnpm keys are scanned exactly the way licenses already were.

This also sidesteps a real bundling failure: snyk's CJS graph does dynamic require() of fs and @snyk/error-catalog-nodejs-public, which broke when inlined via tsup (the alternative fix). Native parsing has no such hazard.

Verification (end-to-end, from the packed tarball)

Built → pnpm pack → installed the tarball into a clean prefix → ran codehub analyze:

  • Warnings: 5 → 2; snyk-nodejs-lockfile-parser absent from the consumer tree; snyk symbols gone from dist.
  • npm v3 package-lock.json: analyze exit 0 — indexed left-pad + @scope/util (scoped, with licenses).
  • pnpm v9 pnpm-lock.yaml: analyze exit 0 — indexed left-pad, @scope/util, react-dom (peer-suffix (react@18.2.0) correctly stripped).

Gates: typecheck ✓ (CI-equivalent, excludes docs per ci.yml), 638 ingestion tests ✓ (incl. +5 new dep-parser fixtures: npm v1/v2/v3, pnpm v9/v6, missing-manifest), biome ✓ (686 files), docs build ✓ (64 pages).

Also in this PR

  • Troubleshooting docs: new section explaining the residual cosmetic glob/inflight warnings are not security issues (CI runs osv/grype/semgrep/npm-audit; overrides pin patched versions), and noting the lockfile-parser warnings are now gone.
  • Stale-doc fix: corrected @duckdb/node-api references in the troubleshooting guide — DuckDB was removed in ADR 0019; onnxruntime-node is the only remaining native binding.

Blast radius

Internal lockfile-parsing implementation only; no public API change. The dependency-ingestion phase output is unchanged (verified by the analyze runs + existing tests).

🤖 Generated with Claude Code

…ockfile-parser

`npm install -g @opencodehub/cli` emitted 5 deprecation warnings; 3 of them
(lodash.clone, lodash.isequal, uuid@8) came from snyk-nodejs-lockfile-parser,
a ~126-package transitive tree the CLI bundled solely to enumerate resolved
packages from a lockfile. Its CJS graph also resisted tsup bundling (dynamic
require of fs + @snyk/error-catalog-nodejs-public), so it could not be inlined.

Replace it with a native parser. All we need from a lockfile is the flat set
of resolved name@version pairs, and every shape already carries that verbatim:
- npm v2/v3: the `packages` map keys each install by node_modules path + version
- npm v1: the nested `dependencies` tree carries a version per node
- pnpm 5/6/9: the `packages:`/`snapshots:` keys are name@version (or legacy
  /name/version), with peer suffixes stripped

The license harvester already string-scanned the same raw lockfile, so the
package list and its licenses now come from one pass over one source of truth.
No YAML dependency added — pnpm keys are scanned the same way licenses already
were. Public API is unchanged — this is an internal implementation swap, so it
lands as a normal patch (no breaking change).

Removes snyk-nodejs-lockfile-parser from both @opencodehub/ingestion and
@opencodehub/cli. Verified end-to-end from the packed tarball: warnings drop
5 -> 2 (remaining glob/inflight are @sourcegraph/scip-python's, tracked
upstream), and `codehub analyze` correctly indexes deps from both a v3
package-lock.json and a v9 pnpm-lock.yaml (incl. scoped names + peer-resolved
versions).

Docs: add a troubleshooting note that the residual glob/inflight warnings are
cosmetic, and correct stale native-binding claims in the troubleshooting guide
and CLAUDE.md — OpenCodeHub has zero native bindings (parsing is web-tree-sitter
WASM, store is built-in node:sqlite, optional embedder is onnxruntime-web WASM;
@duckdb/node-api was removed in ADR 0019, and there is no onnxruntime-node).

Tests: +5 dep-parser fixtures (npm v1/v2/v3, pnpm v9/v6, missing-manifest);
638 ingestion tests pass, biome clean, docs build green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@theagenticguy theagenticguy force-pushed the fix/replace-snyk-lockfile-parser branch from 71db7c0 to 0555388 Compare June 28, 2026 15:58
@theagenticguy theagenticguy merged commit 738511b into main Jun 28, 2026
38 checks passed
@theagenticguy theagenticguy deleted the fix/replace-snyk-lockfile-parser branch June 28, 2026 16:01
@github-actions github-actions Bot mentioned this pull request Jun 28, 2026
theagenticguy pushed a commit that referenced this pull request Jun 28, 2026
🤖 Automated release via release-please
---


<details><summary>root: 0.10.2</summary>

##
[0.10.2](root-v0.10.1...root-v0.10.2)
(2026-06-28)


### Bug Fixes

* **ingestion:** parse npm/pnpm lockfiles natively, drop
snyk-nodejs-lockfile-parser
([#259](#259))
([738511b](738511b))
</details>

<details><summary>cli: 0.10.2</summary>

##
[0.10.2](cli-v0.10.1...cli-v0.10.2)
(2026-06-28)


### Bug Fixes

* **ingestion:** parse npm/pnpm lockfiles natively, drop
snyk-nodejs-lockfile-parser
([#259](#259))
([738511b](738511b))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant