Skip to content

fix(sbom): preserve source version in upstream entry - #1377

Open
kocaemre wants to merge 1 commit into
python-wheel-build:mainfrom
kocaemre:fix/1376-upstream-source-version
Open

kocaemre wants to merge 1 commit into
python-wheel-build:mainfrom
kocaemre:fix/1376-upstream-source-version

Conversation

@kocaemre

Copy link
Copy Markdown

Pull Request Description

What

  • Keep the upstream SBOM package at the resolved source version when purl.upstream is unset; purl.version continues to identify the built wheel.
  • Add a regression validating both SPDX package versions and purls without an explicit upstream override.

Why

Closes #1376. A locally versioned wheel must not make the GENERATED_FROM source reference point to a non-existent upstream release.

Verification

  • RED: uvx --from hatch hatch run test:test tests/test_sbom.py::test_generate_sbom_upstream_uses_source_version_without_upstream_override -q --no-cov --tb=short — 1 failed as expected (upstream.versionInfo: 0.5.5+local.1 instead of 0.5.5).
  • GREEN: uvx --from hatch hatch run test:test tests/test_sbom.py tests/test_packagesettings.py -q --no-cov --tb=short — 108 passed.
  • uvx --from hatch hatch run mypy:check src/fromager/sbom.py — 77 source, 51 test, 7 e2e files checked without errors (repo wrapper checks all three).
  • uvx --from hatch hatch run lint:check and git diff --check — passed.
  • Full suite and end-to-end build not run (repo guide recommends file-scoped tests for small fixes).

AI assistance: Hermes Agent prepared this focused change and its regression; local checks above were run. Commit is DCO signed-off.

Use the resolved source release when no upstream purl is configured, so local wheel version overrides do not misidentify the source.

AI-Assisted-By: Hermes Agent

Closes: python-wheel-build#1376
Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
@kocaemre
kocaemre requested a review from a team as a code owner October 16, 2026 02:30
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: python-wheel-build/fromager/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9425cbc0-de50-43fc-a2ec-9244bf092879
📥 Commits

Reviewing files that changed from the base of the PR and between 45241aa and 7b20afb.

📒 Files selected for processing: 2
  • src/fromager/sbom.py
  • tests/test_sbom.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The fallback upstream PURL now uses the supplied source version instead of the per-package version override. An explicit upstream PURL is still used as-is. A new test checks that the local version applies to the wheel, while the upstream entry retains the source version, and validates the generated SPDX document.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 7b20a

The upstream SBOM entry now tracks the source release even when the built wheel has a local version suffix, preserving accurate provenance. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: preserving the source version in the upstream SBOM entry.
Description check Passed The description directly explains the SBOM version and PURL change, the regression test, the issue addressed, and the verification performed.
Linked Issues check Passed Issue #1376 requires the fallback upstream SBOM entry to retain the resolved source version when purl.upstream is unset. _build_upstream_purl now uses version for that fallback and keeps explici…
Out of Scope Changes check Passed The reviewed changes are limited to upstream purl construction and a focused SBOM regression test. Both changes directly support issue #1376. No unrelated change is shown in the supplied pull request …
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify mergify Bot added the ci label Oct 16, 2026
@rd4398
rd4398 requested a review from mprpic October 16, 2026 13:00

@mprpic mprpic left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Couple minor comments:

  • The doc string in PurlConfig.upstream in src/fromager/packagesettings/_models.py is now outdated after this change.
  • Nit: the repo conventions ask that you use Co-Authored-By as commit trailer, not AI-Assisted-By.

Otherwise, lgtm!

@rd4398

rd4398 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

This looks good to me as well and I agree with @mprpic 's comment above

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SBOM upstream entry uses the purl.version value when purl.upstream is not set

3 participants