Skip to content

Commit b2eee28

Browse files
nirmoyclaude
andcommitted
patchscan: distinguish E: (verification errors) from W: (missing 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>
1 parent 4d02591 commit b2eee28

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

.github/scripts/patchscan

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ def get_src_commit_strs(msg):
3030
# Match common backport/cherry-pick annotations:
3131
# (cherry picked from commit <sha>)
3232
# (backported from commit <sha>)
33-
# upstream commit <sha>
34-
# Upstream commit <sha>
35-
matches = list(re.finditer(r"(?:from commit|[Uu]pstream commit) ([a-fA-F0-9]+)", msg))
33+
# Upstream commit <sha> (only at start of line, used as a trailer)
34+
# Note: "upstream commit <sha>" embedded in prose is intentionally NOT matched
35+
# to avoid false positives from commits that reference upstream SHAs informally.
36+
matches = list(re.finditer(r"(?:from commit|^[Uu]pstream commit) ([a-fA-F0-9]+)", msg, re.MULTILINE))
3637
return list(map(lambda m: m.group(1) if len(m.groups()) == 1 else None, matches))
3738

3839
def references_upstream(commit):

.github/workflows/patchscan.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ jobs:
106106
sed 's/\x1B\[[0-9;]*[A-Za-z]//g; s/\x1B\]8;;[^\x1B]*\x1B\\//g; s/\x1B\]8;;[^\a]*\a//g' \
107107
patchscan_output.txt > patchscan_clean.txt
108108
109-
# Record runtime errors so the comment step can report them before failing
110-
if [ $exit_code -ne 0 ]; then
111-
echo "fixes_found=error" >> $GITHUB_OUTPUT
112-
fi
113-
114-
# Check if missing fixes or scan errors were found
115-
if grep -qE "^W:|^E:|Fixes for" patchscan_clean.txt; then
109+
# Classify the outcome — order matters: W: (missing fixes) takes priority,
110+
# then E: / non-zero exit (verification errors), then all-clear.
111+
# Writing fixes_found twice to GITHUB_OUTPUT would make the last write win,
112+
# so use a single mutually-exclusive block.
113+
if grep -qE "^W:|Fixes for" patchscan_clean.txt; then
116114
echo "fixes_found=true" >> $GITHUB_OUTPUT
115+
elif grep -qE "^E:" patchscan_clean.txt || [ $exit_code -ne 0 ]; then
116+
echo "fixes_found=error" >> $GITHUB_OUTPUT
117117
else
118118
echo "fixes_found=false" >> $GITHUB_OUTPUT
119119
fi
@@ -142,9 +142,12 @@ jobs:
142142
);
143143
144144
const body = [
145-
'## :x: Patchscan: Scan Error',
145+
'## :x: Patchscan: Upstream Verification Error',
146146
'',
147-
'Patchscan encountered an error while scanning this PR:',
147+
'Patchscan could not fully verify one or more commits in this PR.',
148+
'This is often a false positive caused by a SAUCE commit whose message',
149+
'body references an upstream SHA but has a different title.',
150+
'No `Fixes:` patches appear to be missing.',
148151
'',
149152
'````',
150153
truncated.trim(),
@@ -260,7 +263,7 @@ jobs:
260263
if: steps.patchscan.outputs.fixes_found == 'true' || steps.patchscan.outputs.fixes_found == 'error'
261264
run: |
262265
if [ "${{ steps.patchscan.outputs.fixes_found }}" = "error" ]; then
263-
echo "::error::Patchscan encountered a runtime error — see PR comment for details."
266+
echo "::error::Patchscan upstream verification error — see PR comment for details."
264267
else
265268
echo "::warning::Missing upstream fixes detected — see PR comment for details."
266269
fi

0 commit comments

Comments
 (0)