fix(cargo): resolve workspace-inherited license in Cargo.toml#486
fix(cargo): resolve workspace-inherited license in Cargo.toml#486ruromero wants to merge 1 commit into
Conversation
When a Cargo.toml uses `license = { workspace = true }`, the tomlj
library's getString() returns null because the value is an inline table,
not a string. The license is silently dropped from the SBOM.
Fix by using get() to retrieve the raw Object, checking instanceof
String for direct values, and resolving from workspace.package.license
when workspace inheritance is detected — following the existing version
resolution pattern in parseCargoToml().
Fixes: TC-4528
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewer's GuideAdds support for resolving Cargo workspace-inherited licenses from Cargo.toml using tomlj’s generic get/boolean accessors, mirroring existing workspace version resolution logic, and covers the behavior with new unit tests and manifest fixtures. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new license resolution logic in
readLicenseFromTomlwould be easier to follow if you mirrored the existing version-resolution pattern more closely (e.g., extract a small helper that encapsulates the workspace lookup rather than inlining the conditional logic here). - Consider tightening the type checks around
licenseValueby explicitly handling only the expected TOML types (e.g.,TomlTablevs. other non-String values) so that any unexpected structure inpackage.licensefails fast instead of silently falling through.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new license resolution logic in `readLicenseFromToml` would be easier to follow if you mirrored the existing version-resolution pattern more closely (e.g., extract a small helper that encapsulates the workspace lookup rather than inlining the conditional logic here).
- Consider tightening the type checks around `licenseValue` by explicitly handling only the expected TOML types (e.g., `TomlTable` vs. other non-String values) so that any unexpected structure in `package.license` fails fast instead of silently falling through.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Verification Report for TC-4531 (commit 3b8fa90)
Overall: WARNScope Containment (WARN): PR includes Commit Traceability (WARN): The commit trailer references Test Quality (WARN): The 2 new test methods have proper This comment was AI-generated by sdlc-workflow/verify-pr v0.9.0. |
Summary
license = { workspace = true }) viatomlj'sget()method and resolve fromworkspace.package.licenseparseCargoToml()Fixes: TC-4528
Implements: TC-4531
Test plan
🤖 Generated with Claude Code
Summary by Sourcery
Handle Cargo workspace-inherited licenses when reading Cargo.toml manifests.
New Features:
Tests: