Skip to content

Fix #15290 (donate-cpu-server-rest: handle triage results and suggest warnings to triage) - #9091

Merged
danmar merged 1 commit into
cppcheck-opensource:mainfrom
cppchecksolutions:daca-rest-triage
Nov 30, 2026
Merged

danmar merged 1 commit into
cppcheck-opensource:mainfrom
cppchecksolutions:daca-rest-triage

Conversation

@danmar

@danmar danmar commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@dmcppcheck dmcppcheck 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.

AI review

I found no significant problems in the new triage code of tools/donate-cpu-server-rest.py. The PR changes only Python; no C/C++ code changes.

There is one small robustness gap. triage_lines() cuts off exactly 'head ' and doesn't strip the rest of the line again. A warning uploaded as head X (two spaces) is stored as a second entry with the key ' X'. That entry is counted twice in the report, and the next result upload deletes it because ' X' never matches the stripped lines of the result file.

I checked these and found nothing wrong:

  • version checks for uploads
  • lock ordering between the index write lock and the triage lock
  • handling of incomplete or partially written result files (section == 'diff')
  • sampling and duplicate removal in _pick_warnings
  • error handling when triage.json is loaded

There are no earlier review comments.

Comments

# Comment By Where Status
1 'head X' (extra whitespace) is stored as a separate warning and later deleted AI review tools/donate-cpu-server-rest.py:528 🆕 New

@danmar, please fix, resolve or reply to the open and new comments: #1.

Testing

  • I could not run the PR's tests. fastapi, pydantic, jinja2, uvicorn and httpx are not installed and there is no network. python3 -m pytest test/tools/donate_cpu_server_rest_test.py reports 1 skipped. I did not build cppcheck/testrunner because the PR does not touch C++.
  • To test the triage logic without the web server, I stubbed the web modules in /work/scratch/stubs and imported the module. Then I ran TriageStore.merge, triage_report, parse_result and TriageStore.remove_unmatched directly. Matching head X against X, keeping a 2.22.0 X triage result while that warning is still in the diff, and leaving notes out of the key all work as described.
  • Reproducer for the double-space case (/work/scratch/t.py, run with PYTHONPATH=stubs:/work/pr/tools python3 t.py):
W='ccc/a.c:1:2: error: x [arrayIndexOutOfBounds]'
st.merge([{'url':URL,'warning':'head '+W,'verdict':'True positive'},
          {'url':URL,'warning':'head  '+W,'verdict':'True positive'}], lambda u: True)
# -> added: 2 (should be 1 added, 1 unchanged); report: arrayIndexOutOfBounds tp: 2
# after remove_unmatched() with a result file that still contains W: 1 of the 2 entries is deleted

Automated review of 37e3f9e by Claude. The pull request was built and tested locally.

def triage_lines(warning: str) -> Tuple[str, ...]:
"""The warning lines of a triage result. Notes are ignored. 'head X' is the same warning as 'X'."""
lines = [line.strip() for line in warning.splitlines()]
return tuple(line[len('head '):] if line.startswith('head ') else line

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.

AI review

The line is not stripped again after 'head ' is cut off. A warning uploaded as head X (two spaces) gets the key ' X'. It does not match the existing X entry, so the same warning is counted twice in the triage report. remove_unmatched() then deletes it on the next result upload, because the lines of the result file are stripped. Suggestion: line[len('head '):].lstrip(), or normalise with RE_VERSION_PREFIX/split(maxsplit=1).

Reproduced: merging head + W and head + W gives added: 2, and the TP count for the message id is 2.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok

@danmar
danmar merged commit 6a4fedd into cppcheck-opensource:main Nov 30, 2026
74 checks passed
@danmar
danmar deleted the daca-rest-triage branch November 30, 2026 12:26
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