Skip to content

fix: make GitHub PR-description ticket selection deterministic - #3

Open
dellch wants to merge 1 commit into
mainfrom
fix/github-ticket-extraction-deterministic
Open

dellch wants to merge 1 commit into
mainfrom
fix/github-ticket-extraction-deterministic

Conversation

@dellch

@dellch dellch commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Preview on my fork before raising upstream. Split out of the Jira ticket-context PR (The-PR-Agent#2420) because it is a pre-existing bug unrelated to Jira.

Summary

extract_ticket_links_from_pr_description() accumulates GitHub issue URLs in a set, then enforces the 3-ticket cap by slicing list(github_tickets)[:3]. Because sets are unordered, the chosen subset can differ between runs, so which tickets get used for review context is nondeterministic when a PR description references more than 3 issues.

Fix

Track URLs in first-seen order while de-duplicating (a seen set plus an ordered list), then apply the cap by slicing the ordered list. Selection is now stable and predictable.

Notes

Test plan

  • pytest tests/unittest/test_extract_issue_from_branch.py
  • Added tests for first-seen order and deterministic cap selection

Co-Authored-By: Claude

extract_ticket_links_from_pr_description() accumulated issue URLs in a set,
then applied the MAX_TICKETS cap by slicing list(set), which picks an
arbitrary subset that can vary between runs.

Track URLs in first-seen order while de-duplicating (mirroring
find_jira_tickets), so the cap keeps a stable, predictable subset.

Co-Authored-By: Claude
IsmaelMartinez pushed a commit that referenced this pull request Aug 28, 2026
… (The-PR-Agent#2492)

* fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests

- Cache key is now 'related_tickets_<md5(pr_url)>' instead of global
  'related_tickets', preventing stale tickets leaking between unrelated PRs
- Added cache_tickets=true config flag under [pr_reviewer] to allow disabling
- Fixed Dynaconf merge_enabled=True list append bug in both production code
  (env_bridge.py uses case-insensitive pop before set) and test helpers
  (restore_settings now calls _remove_key before every set)
- Added azure-identity dependency for Azure DevOps provider availability
- 1043 tests pass, 0 failures

* Revert "fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests"

This reverts commit 7f0d154.

* feat: support GitHub Checks API as output mechanism (The-PR-Agent#1400)

Add `github.publish_as_check_run` config option (default `false`) that
routes persistent tool output (review, describe, improve) to GitHub
Check Runs instead of PR comments. Check runs appear in the dedicated
Checks tab, reducing comment noise on the main PR conversation.

- `GithubProvider.publish_persistent_comment` delegates to
  `_publish_check_run` when the flag is enabled
- Check runs are created on first invocation and updated on subsequent
  calls (tracked per tool name via `_check_run_ids` dict)
- Falls back to comments gracefully on API errors

* fix: address bot review comments for Checks API (The-PR-Agent#1400)

- Move _check_run_ids from class-level to instance-level dict
- Use self.last_commit_id.sha instead of commit object
- Remove unused headers variable (F841)
- Add fallback to PR comment when check run API fails

* fix: address remaining bot review comments for Checks API (The-PR-Agent#1400)

- Use separate update_body without head_sha for PATCH requests
- Truncate text payload to 65535 chars (GitHub API limit)

* fix: remove exception details from log to avoid leaking API request info

* fix: address review feedback - fix requestJsonAndCheck unpacking, persistent check-run lookup, add tests

* docs: document publish_as_check_run and synchronize event in action setup

* chore: remove accidentally added skpro submodule

* chore: add skpro to gitignore

* fix: address Qodo findings - guard last_commit_id with getattr, add check_run support to improve path

* fix: address Qodo findings on check-run output clobbered and pagination

- Add _next_page_url() helper and paginate _find_existing_check_run
  to follow GitHub Link header across pages (Qodo finding The-PR-Agent#8)
- Pass name="config-errors" to handle_configurations_errors so it
  doesn't clobber other check-run output (Qodo finding #3)
- Fix FakeMarkdownProvider to accept the new name kwarg

---------

Co-authored-by: Utsab <utsab@pr-agent.dev>
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.

1 participant