refactor(cargo): improve lock parse error context and remove dead null-guards - #622
Merged
Conversation
Reviewer's GuideThe PR makes Cargo.lock parse failures actionable by reporting the file path and underlying parser error, adds regression coverage with a malformed lock fixture, and simplifies dependency hash lookups around the guaranteed Map return value. Sequence diagram for Cargo.lock parse failure diagnosticssequenceDiagram
participant CargoProvider
participant CargoLockParser
participant Console
CargoProvider->>CargoLockParser: parseCargoLockHashes(manifestDir, opts)
CargoLockParser-->>CargoProvider: Map or parse error
alt malformed Cargo.lock
CargoLockParser->>Console: console.warn(lockPath, error.message)
CargoLockParser-->>CargoProvider: hashMap
CargoProvider->>CargoProvider: Generate SBOM without hashes
end
Flow diagram for Cargo dependency hash lookupflowchart LR
Parse["parseCargoLockHashes returns Map"] --> Direct["addDirectDeps calls hashMap.get()"]
Parse --> Transitive["addTransitiveDeps calls hashMap.get()"]
Direct --> SBOM["sbom.addDependency with hashes"]
Transitive --> SBOM
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #622 +/- ##
=======================================
Coverage 91.45% 91.45%
=======================================
Files 44 44
Lines 10172 10172
Branches 1840 1838 -2
=======================================
Hits 9303 9303
Misses 869 869
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Strum355
reviewed
Aug 31, 2026
Strum355
left a comment
Member
There was a problem hiding this comment.
I would personally remove the malformed lock test. Feels like a case of Claude being overzealous with adding tests for the tiniest things
Strum355
approved these changes
Aug 31, 2026
…l-guards Add lock file path and error message to the parseCargoLockHashes catch block for descriptive diagnostics, and remove the dead hashMap null-guards in addTransitiveDeps and addDirectDeps (parseCargoLockHashes always returns a Map). Add a test covering the malformed Cargo.lock warning. Implements TC-5729 Assisted-by: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parseCargoLockHashescatch block for descriptive diagnostics (per CONVENTIONS.md error-handling guidance).hashMapnull-guards inaddTransitiveDepsandaddDirectDeps—parseCargoLockHashesalways returns aMap, so all three call sites now use consistent direct.get()access.Cargo.lockwarning (asserts path + error detail inconsole.warn).Testing
npm test -- test/providers/rust_cargo.test.js— 74 passing.Implements TC-5729
Summary by Sourcery
Improve Cargo.lock parsing diagnostics and simplify dependency hash handling.
Enhancements:
Tests: