Repository navigation
fix: try_fix_yaml failed on snippets with prefix or yml - #2097
Conversation
more robust try_fix_yaml
test extract snippet with prefix "```" or "```yml"
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 |
|||||||||||||||||||||||
PR Code Suggestions ✨Latest suggestions up to 46f889b
Previous suggestions✅ Suggestions up to commit 46f889b
|
||||||||||||||||||||||||
|
Hi @LawrenceMantin 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! |
|
/improve |
|
Persistent suggestions updated to latest commit 46f889b |
|
/agentic_review |
Code Review by Qodo
1.
|
Extract the YAML snippet directly from the regex capture group instead
of taking the full match and manually detecting/stripping the ```yaml,
```yml, or ``` prefix and trailing backticks. Same behavior, less
string juggling, and avoids rstrip('`') accidentally eating legitimate
trailing backticks in the content.
|
Persistent review updated to latest commit 7b69b64 |
Replace the bare except with `except Exception as e:` and a debug log, addressing the agentic review flag on PR The-PR-Agent#2097. Matches the `except Exception as e:` + get_logger() convention used elsewhere in utils.py.
|
Persistent review updated to latest commit d2070e2 |
Replace the bare `except:` with `except Exception:` so the fallback no longer swallows KeyboardInterrupt/SystemExit, addressing the agentic review flag on PR The-PR-Agent#2097. Kept silent (`pass`) to stay consistent with the other fallback rungs in try_fix_yaml.
|
Persistent review updated to latest commit d2070e2 |
|
Hey @XinyuWuu, Sorry for the delay on this one. |
User description
LLMs might return code wrapped with ``` or ```yml.
PR Type
Bug fix
Description
Enhanced
try_fix_yamlto handle code snippets with\``,```yaml, or```yml` prefixesUpdated regex pattern to match optional language identifiers (yaml/yml)
Added dynamic prefix detection to correctly remove code fence markers
Extended test coverage with three snippet format variations
Diagram Walkthrough
File Walkthrough
utils.py
Enhance regex and prefix handling for code fencespr_agent/algo/utils.py
snippet_patternregex fromr'yaml([\s\S]*?)(?=\s*$|")'tor'(yaml|yml)?([\s\S]*?)(?=\s*$|")'to match optional languageidentifiers
starts with
\\\yaml,\\\yml, or plain\\\Modifiedremoveprefix()call to use detected prefix instead of'hardcoded
yaml'test_try_fix_yaml.py
Add test cases for multiple code fence formatstests/unittest/test_try_fix_yaml.py
review_texttoreview_text1forclarity
review_text2test case with\\\ymlprefix format
Addedreview_text3test case with plain\\\prefix format