Skip to content

Handle non-string and dict dependencies in pubspec build_dep - #5497

Open
Adnan9-63 wants to merge 1 commit into
aboutcode-org:developfrom
Adnan9-63:fix/5491-pubspec-build-dep
Open

Adnan9-63 wants to merge 1 commit into
aboutcode-org:developfrom
Adnan9-63:fix/5491-pubspec-build-dep

Conversation

@Adnan9-63

Copy link
Copy Markdown

What changes does this PR introduce?

This PR resolves an unhandled AttributeError in build_dep (src/packagedcode/pubspec.py) where Dart pubspec.yaml files declare path dependencies (path: ../local_pkg), git dependencies (git: {url: ...}), or unversioned dependencies (pkg: with None value). Calling .replace('.', '').isdigit() on non-string inputs previously caused package detection to fail completely.

Specifically:

  1. Robust Dependency Type Handling: Handles dict dependencies (preserving dictionary metadata in extra_data while extracting version or SDK strings), str, and None/non-string values safely.
  2. Type-Guarded Pinning Check: Guards .replace('.', '').isdigit() to ensure it only evaluates when extracted_requirement is a valid string.
  3. Unit Tests: Added 4 data-driven unit regression tests in tests/packagedcode/test_pubspec.py covering path, git, hosted, and unversioned dependencies.

Fixes #5491

Checklist

  • Code passes tests: pytest tests/packagedcode/test_pubspec.py
  • DCO sign-off applied to commit

Signed-off-by: Adnan9-63 <muhammad1414114@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@Adnan9-63
Adnan9-63 requested a lite review from Copilot November 17, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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] build_dep in pubspec.py crashes with AttributeError on path, git, or unversioned dependencies

2 participants