Skip to content

Improve declared license collection from nuspec files (#2669) - #5271

Draft
teyesan wants to merge 6 commits into
aboutcode-org:developfrom
teyesan:improve-declared-license-detection
Draft

Improve declared license collection from nuspec files (#2669)#5271
teyesan wants to merge 6 commits into
aboutcode-org:developfrom
teyesan:improve-declared-license-detection

Conversation

@teyesan

@teyesan teyesan commented Aug 17, 2026

Copy link
Copy Markdown

Bug: The NuGet .nuspec parser mishandled elements that had a type attribute (e.g. LICENSE.txt) xmltodict returns a dict for attributed elements, and the parser was stringifying the whole dict into extracted_license_statement instead of extracting the actual value.

Fix: Parser now branches on type:

type="file" → filename stored in extra_data.license_file, extracted_license_statement left null
type="expression" → SPDX expression extracted directly into extracted_license_statement
Falls back to deprecated licenseUrl only when no element exists

Tests added: 5 nuspec fixtures covering the full decision tree: type="file" (original bug case), type="expression" (same bug, different branch), plain with no attribute, licenseUrl-only fallback, and no license info at all. Also regenerated fizzler.expected.json, a pre-existing integration fixture that had the old buggy output baked in.

Fixes #2669

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@teyesan there are no test files for your tests.

Comment thread tests/packagedcode/test_nuget.py Outdated



def test_parse_creates_package_from_nuspec_specflow_mstest_license_file(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@teyesan

teyesan commented Aug 19, 2026

Copy link
Copy Markdown
Author

Two tests are designed to fail currently and will pass once fix has been pushed.

Signed-off-by: Temi Eyesan <teyesan06@icloud.com>
Signed-off-by: Temi Eyesan <teyesan06@icloud.com>
@teyesan
teyesan force-pushed the improve-declared-license-detection branch from 9eba4de to c9ea9fb Compare August 19, 2026 20:56
@teyesan teyesan changed the title Updated Tests for Nuget Fix for issue declared license collection from nuspec (#2669) Aug 20, 2026
@teyesan
teyesan force-pushed the improve-declared-license-detection branch from 6df7db8 to bded38b Compare August 21, 2026 02:07
@teyesan teyesan changed the title Fix for issue declared license collection from nuspec (#2669) Improve declared license collection from nuspec files (#2669) Aug 21, 2026
Signed-off-by: Temi Eyesan <teyesan06@icloud.com>
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.

Improve declared license collection from nuspec

3 participants