Skip to content

Handle dict dependency versions in Dart pubspec parsing - #5488

Open
sujalgiriiitp-source wants to merge 1 commit into
aboutcode-org:developfrom
sujalgiriiitp-source:pubspec-dict-versions-5482-fix
Open

sujalgiriiitp-source wants to merge 1 commit into
aboutcode-org:developfrom
sujalgiriiitp-source:pubspec-dict-versions-5482-fix

Conversation

@sujalgiriiitp-source

Copy link
Copy Markdown

Bug: Dart pubspec parsing aborted with AttributeError: 'dict' object has no attribute 'replace' when a path dependency dict (e.g. _json_serial_shared_test: {path: ../shared_test}) appeared in dev_dependencies — build_dep() in src/packagedcode/pubspec.py assumed version is always a string, so the whole parse returned 0 packages.

Fix: dict versions are stringified generically (generalizing the existing sdk case — e.g. path: ../shared_test), and non-string scalar versions are coerced to str.

Verification: the real json_serializable 6.15.2 pubspec (from pub.dev) now parses to 1 package + 24 dependencies; a scan of the extracted tarball contents returns the json_serializable 6.15.2 package. tests/packagedcode/test_pubspec.py: 13 passed (12 existing + 1 new datadriven test from the added regression fixture deps-versions-path-git-hosted-pubspec.yaml, covering path/git/hosted mappings). Note: a CLI scan of the .tar.gz file itself still returns 0 packages in the test environment because that ScanCode build doesn't auto-extract archives during scan — pre-existing environment behavior, unrelated to the parser; direct extractcode extraction works.

Fixes #5482

Signed-off-by: Sujal Giri sujalgiriiitp@gmail.com

Fixes aboutcode-org#5482

Signed-off-by: Sujal Giri <sujalgiriiitp@gmail.com>

This branch has not been deployed

No deployments
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.

[Bug] Running scan on Dart package does not return any packages or dependencies

1 participant