fix(pr_agent/tools/pr_code_suggestions.py): reporting no suggestions when the key is missing - #2903
Conversation
…when the key is missing
…g a response without suggestions
|
Closing as a duplicate of your own #2730, which adds the same guard to the same function, fixes One thing to carry over there before it goes in. #2867 merged at 08:10 today, about forty minutes after you opened this, so you could not have seen it. It counts a chunk as failed only when Thanks for both of these. |
Closes #2902.
Description
_prepare_pr_code_suggestionsiteratesdata['code_suggestions']without checking that the key exists or holds a list.Root cause
Answering in prose when there is nothing to suggest is the behaviour of a helpful assistant, and it is
exactly the case the tool should report cleanly. Instead it is the case that loses the run.
The fix
Validate the parsed payload once, before the loop: anything that is not a dict carrying a
code_suggestionslist is logged with the raw prediction and reported as an empty suggestion list.Behaviour change
/improverunFiles changed
Testing
Written test-first: the test was committed red, then the fix turned it green.
New regression coverage in
tests/unittest/test_improve_missing_suggestions_key.py— 7 tests:Proven to be a genuine regression test: with every changed
pr_agent/file reverted to its739ea8a6version and the new test file left in place, the suite fails. It only passes with the fix applied.
Full unit suite on this branch:
The 3 failures are
tests/unittest/test_extra_config_url.py, which fail identically on unmodifiedmainin thissandbox because they need outbound network; they pass in CI.
Also checked:
ruff— no new findings vsmain;isort— clean on every file touchedRisk / compatibility
The existing normalisation of a top-level list is preserved and still tested. Only inputs that used to raise now return an empty list.