fix(pr_agent/algo/utils.py): rendering todo sections returned as free text - #2901
Open
dwin-gharibi wants to merge 2 commits into
Open
fix(pr_agent/algo/utils.py): rendering todo sections returned as free text#2901dwin-gharibi wants to merge 2 commits into
dwin-gharibi wants to merge 2 commits into
Conversation
Contributor
Author
|
/agentic_review |
Contributor
IsmaelMartinez
left a comment
Collaborator
There was a problem hiding this comment.
Thanks. Same class as #2899 and the crash is real, but the output has a hole.
format_todo_item(None) returns the string "None", which is truthy, so the if entry filter does not drop it and the published review carries a literal <li>None</li>.
Worth knowing that test_skip_an_entry_that_carries_no_usable_text is documented as preventing exactly that, but its only assertion is "fix" in out, so it passes while the None still renders. The one-line guard below keeps your six tests green.
| TODOs in prose instead of locating each one. Such an entry has no file to link to. | ||
| """ | ||
| if not isinstance(todo_item, dict): | ||
| return str(todo_item).strip() |
Collaborator
There was a problem hiding this comment.
Suggested change
| return str(todo_item).strip() | |
| return str(todo_item).strip() if todo_item is not None else "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2900.
Description
format_todo_itemcalls.get()on each entry. The prompt declarestodo_sections: Union[List[TodoSection], str], so a string is part of the contract — but only the exact value"No"is handled.Root cause
The renderer implements only half of the declared union.
is_value_no()recognises"No", and every otherstring falls through to
format_todo_item, which assumes a mapping.The fix
format_todo_itemreturns the text as-is for a non-mapping entry, and for a mapping with norelevant_fileit returns just the content rather than an empty file reference.format_todo_itemsnormalisesthe input once, drops entries with nothing to show, and keeps the existing
<p>rendering for a singlenon-list item so previously pinned output is unchanged.
Behaviour change
AttributeErrorand the review is discardedFiles changed
Testing
Written test-first: the test was committed red, then the fix turned it green.
New regression coverage in
tests/unittest/test_review_todo_sections_shape.py— 6 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 documented shape takes the same path.
tests/unittest/test_markdown_ticket_output_core.pypins the<p>wrapper for a single non-list item and still passes unmodified.