Skip to content

patchscan: distinguish E: (verification errors) from W: (missing fixes)#368

Closed
nirmoy wants to merge 1 commit into
NVIDIA:github-actionsfrom
nirmoy:fix-patchscan-e-vs-w
Closed

patchscan: distinguish E: (verification errors) from W: (missing fixes)#368
nirmoy wants to merge 1 commit into
NVIDIA:github-actionsfrom
nirmoy:fix-patchscan-e-vs-w

Conversation

@nirmoy

@nirmoy nirmoy commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Bug: E: (upstream commit-message mismatch) and W: (missing Fixes: patch) both set fixes_found=true, so the :warning: Missing Fixes Detected comment appeared even when All fixes: was empty and no patches were actually missing.
  • Root cause 1: Two separate if blocks both wrote to GITHUB_OUTPUT for the same variable; the second write (true/false) always overwrote the first (error).
  • Root cause 2: The [Uu]pstream commit regex in get_src_commit_strs() matched upstream commit <sha> embedded in prose (e.g. "was removed by upstream commit d18f1b7"), not just as a backport trailer. Jacob's original script uses only from commit, which correctly ignores such prose references.
  • Fix 1: Replace two independent if blocks with a single mutually-exclusive if/elif/else chain:
    • W: / Fixes forfixes_found=true → "Missing Fixes Detected" comment
    • E: / non-zero exit → fixes_found=error → "Upstream Verification Error" comment
    • neither → fixes_found=false → all-clear comment
  • Fix 2: Anchor [Uu]pstream commit to line start with re.MULTILINE so it only matches as a standalone trailer, not in prose.

Triggered by PR #342, where commit ad33ca9f (a SAUCE config commit) had upstream commit d18f1b7beadf in its description prose — not a backport marker — causing a spurious failure.

Test plan

  • Re-run patchscan against a PR with only E: errors — should post :x: Upstream Verification Error comment and fail the check
  • Verify a PR with actual missing Fixes: patches still posts :warning: Missing Fixes Detected
  • Verify a clean PR still posts :white_check_mark: No Missing Fixes
  • Verify ad33ca9f-style prose reference (upstream commit X not at line start) is no longer matched

Tested on nirmoy/NV-Kernels fork — see comments below for details.

🤖 Generated with Claude Code

@nirmoy nirmoy requested a review from ianm-nv April 16, 2026 13:27
@nirmoy

nirmoy commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator Author

Tested all three paths against the fork (nirmoy/NV-Kernels) with the fix applied:

Test PR Result Comment posted
E: only — SAUCE commit references upstream SHA with different title #9 ❌ fail :x: Patchscan: Upstream Verification Error
W: — commit with backported SHA that has a missing Fixes: patch #8 ⚠️ fail :warning: Patchscan: Missing Fixes Detected
Clean — no upstream references #6 ✅ pass :white_check_mark: Patchscan: No Missing Fixes

The E: case previously posted a misleading "Missing Fixes Detected" comment with an empty All fixes: section. It now correctly posts "Upstream Verification Error" with an explanation that this is often a false positive from SAUCE commits.

@nvmochs

nvmochs commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

I don't have an issue with this change. However, why did the script think the "PCI/AER: Replace PCIEAER_CXL symbol with CXL_RAS" reference was an upstream SHA? Shouldn't it only consider those that have a pick tag?

@nvmochs

nvmochs commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

When I run Jacob's patchscan on Jiandi's CXL branch it did not flag anything for that patch:

❯ patchscan HEAD~5..HEAD upstream master 
Fetching upstream upstream/master...
Checking 5 commits...
checking 5c7000239d1f361f5e8048f4e2ce3a7f9f75e619 NVIDIA: VR: SAUCE: [Config] Add PCI_CXL annotation for CXL state save/restore..... no upstream reference
checking 51885043a12289fecc405e84fd7910d2e982fddc NVIDIA: VR: SAUCE: [Config] Enable CXL DAX and KMEM built-in for CXL memory access..... no upstream reference
checking ad33ca9f32214a31e6ee40573d6c844e9557d8ae NVIDIA: VR: SAUCE: [Config] CXL config annotations for Type-2 device and RAS support..... no upstream reference
checking fc562f73981b9e22e810e2f1f50612935cefc627 NVIDIA: VR: SAUCE: Documentation: ABI: Add CXL PCI cxl_reset sysfs attribute..... no upstream reference
checking 43a1ddec5c38b4d1bbf32ceb3f9827c662a25793 NVIDIA: VR: SAUCE: cxl: Add cxl_reset sysfs interface for PCI devices..... no upstream reference
All fixes:

Previously, both E: (upstream commit-message mismatch) and W: (missing
Fixes: patch) set fixes_found=true, causing the "Missing Fixes Detected"
comment to appear even when no Fixes: patches were missing.  PR NVIDIA#342
triggered exactly this: a SAUCE config commit referencing an upstream SHA
with a different title caused E: output, but All fixes: was empty.

Replace the two separate if-blocks (which could overwrite each other via
GITHUB_OUTPUT) with a single mutually-exclusive chain:
  W: / "Fixes for"  → fixes_found=true  (missing Fixes: patches)
  E: / non-zero rc  → fixes_found=error  (upstream verification failure)
  neither           → fixes_found=false  (all-clear)

Update the "error" PR comment title and body to explain this is typically
a false positive from SAUCE commits that reference upstream SHAs in their
message body with a different title.

Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nirmoy nirmoy force-pushed the fix-patchscan-e-vs-w branch from 323edb6 to dbd7b00 Compare April 16, 2026 15:20
@nirmoy

nirmoy commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator Author

The fight #356 beweeen claude abd copilot must have forced claude to modify the Jacob's script. Checking..

@nirmoy

nirmoy commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator Author

Shouldn't it only consider those that have a pick tag?

You're correct — the original script does exactly that. The [Uu]pstream commit pattern was added to .github/scripts/patchscan during the PR #356 review process to support an additional trailer format (Upstream commit <sha> as a standalone line). Without anchoring it to the start of a line, it also matched upstream commit appearing in prose, which is what ad33ca9f contains:

...was removed from Kconfig by upstream commit d18f1b7beadf
(PCI/AER: Replace PCIEAER_CXL symbol with CXL_RAS) which is included
in this port.

The fix applied in this PR adds re.MULTILINE and a ^ anchor so it only matches as a line-start trailer:

re.finditer(r"(?:from commit|^[Uu]pstream commit) ([a-fA-F0-9]+)", msg, re.MULTILINE)

With this fix ad33ca9f correctly returns "no upstream reference", matching Jacob's original script behaviour.

— Claude

@nirmoy

nirmoy commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by a new PR that also adds 26.04_linux-nvidia support.

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.

2 participants