Repository navigation
Fix #15290 (donate-cpu-server-rest: handle triage results and suggest warnings to triage) - #9091
Conversation
… warnings to triage)
dmcppcheck
left a comment
There was a problem hiding this comment.
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.jsonis 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,uvicornandhttpxare not installed and there is no network.python3 -m pytest test/tools/donate_cpu_server_rest_test.pyreports1 skipped. I did not buildcppcheck/testrunnerbecause the PR does not touch C++. - To test the triage logic without the web server, I stubbed the web modules in
/work/scratch/stubsand imported the module. Then I ranTriageStore.merge,triage_report,parse_resultandTriageStore.remove_unmatcheddirectly. Matchinghead XagainstX, keeping a2.22.0 Xtriage 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 withPYTHONPATH=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 deletedAutomated 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 |
There was a problem hiding this comment.
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.
No description provided.