fix(scripts): verify PR exists before setting pending-review (#40)#43
fix(scripts): verify PR exists before setting pending-review (#40)#43
Conversation
The cleanup trap in autonomous-dev.sh now checks for an open PR referencing the issue before transitioning to pending-review. If the agent exits 0 but no PR was created, it falls back to pending-dev with a warning comment, avoiding a wasted review dispatch cycle.
|
/q review |
There was a problem hiding this comment.
Review Summary
This PR successfully implements PR existence verification before transitioning to pending-review status, addressing issue #40. The implementation is solid with proper error handling and security considerations.
Key Changes Validated:
- PR existence check correctly uses regex patterns to match issue references without false positives
- Proper fallback to
pending-devwhen agent exits 0 but no PR exists - ISSUE_NUMBER validation prevents injection attacks
- Comprehensive unit tests cover all scenarios
Security & Quality:
- Input validation for ISSUE_NUMBER (lines 80-83) prevents command injection
- Error handling with
2>/dev/null || echo "0"ensures safe fallback - Regex pattern correctly matches issue references (e.g.,
#40) without matching partial numbers (e.g.,#140)
No blocking issues identified. The implementation is ready to merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
There was a problem hiding this comment.
Summary
This PR addresses issue #40 by adding a PR existence check before transitioning to pending-review status. The implementation prevents wasted review cycles when the agent exits successfully without creating a PR.
Critical Issue Found
PR Detection Logic: The current regex pattern for detecting PR existence has a logic flaw that can produce false positives. Any open PR mentioning the issue number (e.g., "related to #40") will be counted, even if it wasn't created to resolve that issue. The fix should use GitHub's standard linking keywords (Fixes/Closes/Resolves) to ensure only PRs that actually resolve the issue are detected.
Overall Assessment
The approach is sound, but the PR detection logic needs correction to prevent false positives. Once the regex pattern is updated to match standard GitHub issue resolution keywords, this will effectively solve the problem described in issue #40.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
Summary
autonomous-dev.shcleanup trap before settingpending-reviewpending-devwith a warning commentFixes #40
Design
docs/designs/fix-cleanup-pr-check.md)Test Plan
docs/test-cases/fix-cleanup-pr-check.md)Checklist
tests/unit/test-cleanup-pr-check.sh)