Skip to content

fix(scripts): verify PR exists before setting pending-review (#40)#43

Merged
zxkane merged 1 commit intomainfrom
fix/issue-40-cleanup-pr-check
Mar 29, 2026
Merged

fix(scripts): verify PR exists before setting pending-review (#40)#43
zxkane merged 1 commit intomainfrom
fix/issue-40-cleanup-pr-check

Conversation

@zxkane
Copy link
Copy Markdown
Owner

@zxkane zxkane commented Mar 29, 2026

Summary

  • Add PR existence check in autonomous-dev.sh cleanup trap before setting pending-review
  • When agent exits 0 but no PR was created, fall back to pending-dev with a warning comment
  • Prevents wasted review dispatch cycles and confusing retry counting

Fixes #40

Design

  • Design canvas created (docs/designs/fix-cleanup-pr-check.md)
  • Design approved

Test Plan

  • Test cases documented (docs/test-cases/fix-cleanup-pr-check.md)
  • Unit tests pass (7 new + 41 existing = 48 total)
  • CI checks pass
  • Code simplification review passed
  • PR review agent review passed
  • Reviewer bot findings addressed
  • E2E tests pass

Checklist

  • New unit tests written (tests/unit/test-cleanup-pr-check.sh)
  • Documentation updated

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.
@zxkane
Copy link
Copy Markdown
Owner Author

zxkane commented Mar 29, 2026

/q review

Copy link
Copy Markdown

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-dev when 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.

Copy link
Copy Markdown

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zxkane zxkane merged commit 076b143 into main Mar 29, 2026
3 checks passed
@zxkane zxkane deleted the fix/issue-40-cleanup-pr-check branch March 29, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scripts): autonomous-dev.sh cleanup sets pending-review without verifying PR exists

1 participant