Repository navigation
fix: recognize generated descriptions with leading content - #2667
IsmaelMartinez merged 2 commits into
Conversation
PR Summary by QodoFix pr-agent generated-description detection with leading content
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
00ec8aa to
27872a8
Compare
…ml crash Three changes addressing maintainer feedback on The-PR-Agent#2667: 1. Hidden HTML comment injected at write time in pr_description.py. Detection checks for it anywhere in the body first (fast path), then falls back to startswith against the standard header list. This avoids the false-positive of matching visible headers anywhere. 2. Removed fallback that matched visible pr-agent headers anywhere. With the hidden marker as primary signal, this caused false positives when human text quoted a pr-agent header (IsmaelMartinez review Aug 18). 3. Fixed load_yaml crash: _prepare_data now handles None return from load_yaml (the other half of The-PR-Agent#2633). Returns empty dict instead of crashing with TypeError. 11 tests pass; full unit suite 1947 passed, 0 new failures. Fixes The-PR-Agent#2633
|
Thanks for the thorough review, @IsmaelMartinez. Reworked per your feedback: 1. Hidden HTML marker instead of matching visible headers anywhere. A 2. Removed the visible-header-anywhere fallback. With the hidden marker as the primary signal, matching visible pr-agent headers anywhere is no longer needed and was the source of the false positive. 3. Fixed Verification: 11 tests in
Full unit suite: 1947 passed, 0 new failures. |
|
Code review by qodo was updated up to the latest commit 27872a8 |
|
Green and the tests bite, but I do not think this does what the title says. Running Could the visible-header path tolerate leading content too, rather than the marker alone? The Thanks for contributing! |
|
A correction to my note above: the leading blank line case does work, because |
…he-PR-Agent#2667) Two changes addressing maintainer feedback on The-PR-Agent#2667: 1. Hidden HTML comment injected at write time in pr_description.py. Detection checks for it anywhere in the body first (fast path), then falls back to header matching. This catches new pr-agent output regardless of leading content. 2. Visible-header detection tolerates leading content for headers unique to pr-agent (PR Type, PR Description, etc.) by using `in` instead of `startswith`. Generic headers (Description, Type, Labels) still require startswith to avoid misclassifying human descriptions that happen to contain these common markdown headings. The load_yaml None guard from the original The-PR-Agent#2667 commit is intentionally excluded per maintainer request to split it into its own PR. 23 new tests cover: hidden marker detection, leading-content tolerance, generic header startswith enforcement, and edge cases. Full suite: 2213 passed, zero failures. Fixes The-PR-Agent#2633
27872a8 to
464d00b
Compare
|
Reworked per your feedback. Two changes:
The 23 new tests cover: hidden marker detection, leading-content tolerance for each unique header, generic header startswith enforcement, and edge cases. Full suite 2213 passed, zero failures. PR head updated to 464d00b. |
|
Code review by qodo was updated up to the latest commit 464d00b |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for reworking this, and the hidden marker is the right mechanism.
The visible-header half needs one more turn. Qodo's finding 5 asked for recognition of unquoted markers "while preserving protection against quoted human content"; the anywhere-match delivers the first half and drops the second. A description that quotes our headers is now read as ours, and get_user_description returns '', so the text is dropped on the next describe.
What the suggestion cannot close is a verbatim paste with the header on its own line, since that is byte-identical to a legacy description with a line prepended. The marker is what settles those going forward.
| for header in possible_headers: | ||
| if header in self._UNIQUE_PR_AGENT_HEADERS and header in description_lowercase: | ||
| return True |
There was a problem hiding this comment.
Requiring the header to start its own line keeps the ratchet fix and stops a quoted copy counting. It closes the blockquote, inline-backtick and indented cases; your 23 tests stay green and the suite stays at 2273.
| for header in possible_headers: | |
| if header in self._UNIQUE_PR_AGENT_HEADERS and header in description_lowercase: | |
| return True | |
| for header in possible_headers: | |
| if header in self._UNIQUE_PR_AGENT_HEADERS and ( | |
| description_lowercase.startswith(header) | |
| or ("\n" + header) in description_lowercase): | |
| return True |
Matching the unique headers anywhere meant a human description that quotes them was read as generated, so get_user_description returned '' and their text was dropped on the next describe. Requiring the header at line start keeps the leading-content fix and ignores quoted copies. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit 187398c |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
I pushed the line-start variant myself rather than leave you another round: the unique headers now have to start their own line, so a quoted copy is not read as ours. Your 23 tests still pass and I added four guards.
Thanks for the rework, the hidden marker is the right mechanism and it is what makes this safe going forward.
Description
Fixes #2633.
GitProvider._is_generated_by_pr_agentonly recognized pr-agent output when the description started with one of the standard headers. If the model places anything above the first header (in the reported case, a one-line instruction leaked in viaextra_instructions), recognition fails, the entire previous description including prior AI content is classified as user text, and the next/describerepublishes it under### **User description**. Each run adds one nesting layer, so descriptions grow without bound (74k characters observed, eventually crashingload_yamlinpr_description.py).The fix recognizes generated output by its unique section markers (
### **PR Type**,### **PR Description**,### **PR Labels**,### 🤖 Generated by PR Agent) anywhere in the body, while keeping thestartswithcheck for the generic headers. Only pr-agent-specific markers are matched anywhere, so a human description that merely contains a generic header like### **Description**is not misclassified.get_user_descriptionalready extracts between theUser descriptionheader and the next header, so leading noise is simply skipped and never re-embedded.This is fix (b) from the issue (relax recognition), scoped to pr-agent-unique markers to avoid false positives on human-written descriptions.
Verification
tests/unittest/test_git_provider_description_recognition.py(7 tests): regression tests for recognition with leading content, clean generated descriptions, plain user descriptions, generic-header-in-middle safety, andget_user_descriptionextraction.Impact: any pr-agent user on any provider (GitHub, GitLab, Bitbucket, etc.) whose generated description carries leading content. Existing already-grown descriptions stop growing on the next
/describe; a fresh run produces a normal description.