fix: YAML parser error from diff-style lines in nested lists - #2061
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
|
/review |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
|
Hi @isExample We offer a free Qodo version for free-trial for developers [www.qodo.ai], We’re currently restructuring the project and contributing it to the community, with plans to move it under a foundation. We’ll also be launching an Ambassador Program soon — if you’d like to join, stay tuned for more details! |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thank you for this, and I am sorry it sat: 318 days with nobody looking at it. It is also still needed.
The bug reproduces on today's main. Your /improve shape does not fail loudly there, it silently loses data: a block scalar carrying - markers swallows the keys that follow it into itself. The same markers on the /review schema are worse. key_issues_to_review with - prefixed block content returns None outright on main, and parses correctly with your fallback applied.
Two small things if you are still around. Rebase: only test_try_fix_yaml.py conflicts, because main appended a test in the same place, so it is a keep-both. And widen the regression test to cover the /review shape, since that is the harder failure and the current test does not reach it.
If you would rather not pick it back up, say so and I will land it with credit to you.
# Conflicts: # tests/unittest/test_try_fix_yaml.py
Matches the guard The-PR-Agent#2618 added to the other eleven fallbacks, so an input that reaches this branch but still parses to None no longer logs success alongside the failure that follows. Narrows this block's bare except at the same time. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VZ8kYURUMYetyihrfZMEz
| if data is not None: | ||
| get_logger().info("Successfully parsed AI prediction after normalizing diff removal markers") | ||
| return data | ||
| except Exception: |
Code Review by Qodo
1. except silently suppresses YAML errors
|
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Sorted, and merging. I pushed the merge with main onto your branch, added the data is not None guard the other eleven fallbacks got in #2618, and narrowed this block's bare except to clear Qodo's finding. Your commits are untouched.
CI is green again on the new head, for the first time since October. Thanks for the fix and for the long wait on our side.
User description
While using pr-agent, I repeatedly ran into YAML parsing errors when using the

describeorimprovetools on GitHub PRs.Here’s one of the error examples I encountered:
I found that the issue was caused by AI-generated diffs inserting diff-style prefixes (
-,+,-+, etc.) inside YAML lists. This confused the parser and caused every fallback in try_fix_yaml to return None.So I added a regression test reproducing the failure and implemented the 5.5 fallback to handle it.

As a result, the previously failing cases now pass cleanly:
PR Type
Bug fix
Description
Fix YAML parser error from diff-style markers in nested lists
Add fallback to normalize diff markers before parsing
Include regression test for diff marker handling
Diagram Walkthrough
File Walkthrough
utils.py
Add YAML diff marker normalization fallbackpr_agent/algo/utils.py
-,+,-+patternstest_try_fix_yaml.py
Add regression test for diff marker handlingtests/unittest/test_try_fix_yaml.py
-,+,-+markers in list items