fix(lockfile): accept scalar os/cpu/libc in npm package-lock.json#405
fix(lockfile): accept scalar os/cpu/libc in npm package-lock.json#405
Conversation
npm sometimes emits these platform fields as scalar strings rather than arrays (e.g. sass-embedded-linux-arm@1.99.0 ships "libc": "glibc"), and verbatim-roundtripped lockfiles preserve the shape. The pnpm + bun parsers already accepted both shapes via aube_util::string_or_seq; extend the npm parser the same way and add a regression test using the exact shape reported in discussion #336. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes npm Confidence Score: 5/5Safe to merge — minimal, targeted fix with direct regression test coverage. Single-file change applies an existing, well-tested helper to three fields, exactly mirroring the pnpm and bun parsers. The regression test directly reproduces the reported failure shape. No logic changes elsewhere. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(lockfile): accept scalar os/cpu/libc..." | Re-trigger Greptile |
Summary
package-lock.jsonparser. The pnpm parser learned to accept scalarlibc/os/cpu(e.g."libc": "glibc") but the npm parser still required arrays, so verbatim-roundtripped lockfiles containingsass-embedded-linux-*and friends fail to parse.RawNpmPackage::{os,cpu,libc}toaube_util::string_or_seq, the same helper bun and pnpm already use.Test plan
cargo test -p aube-lockfile --lib npm::cargo clippy -p aube-lockfile --all-targets -- -D warningscargo fmt --check🤖 Generated with Claude Code
Note
Low Risk
Low risk: small, localized change to npm lockfile deserialization to accept an additional JSON shape, with a focused regression test covering the new behavior.
Overview
Fixes npm
package-lock.jsonparsing to accept platform fieldsos,cpu, andlibcwhen npm emits them as scalar strings instead of arrays, by deserializing them viaaube_util::string_or_seq.Adds a regression test that parses a minimal v3 lockfile containing scalar
os/cpu/libc(e.g.sass-embedded-linux-arm) and asserts the values are captured correctly.Reviewed by Cursor Bugbot for commit d164b37. Bugbot is set up for automated code reviews on this repo. Configure here.