Skip to content

fix(protocol): prs_for_issue and issue_for_pr work on a real gh (#89) - #93

Merged
glennfaison merged 1 commit into
mainfrom
fix/89-pr-author-association
Nov 10, 2026
Merged

glennfaison merged 1 commit into
mainfrom
fix/89-pr-author-association

Conversation

@glennfaison

Copy link
Copy Markdown
Owner

Closes #89.

What

prs_for_issue and issue_for_pr asked gh pr list and gh pr view for authorAssociation. That is not a PR field in any gh release, so on a real gh both fail with Unknown JSON field, and an agent cannot find the PR that belongs to an issue. That is what stops implement-github-issue from opening a second PR for an issue that already has one, and what reconcile-github-issues uses to settle agent:pr-open issues.

  • prs_for_issue reads the REST pull requests (gh api repos/{owner}/{repo}/pulls?state=all, two pages of 100, so the same 200 newest as before). They carry author_association and user.login, so the existing trusted_jq applies unchanged. State is mapped back to OPEN|MERGED|CLOSED, so the output is the same.
  • issue_for_pr reads the REST pull request for the description and the author, and gh pr view --json closingIssuesReferences for GitHub's own links. closingIssuesReferences needs gh 2.72 or newer (I checked the release sources: 2.71 lacks it, 2.72 has it). With an older gh only that "Unknown JSON field" error is tolerated, and the description is still read for Closes #N and a trusted marker. Any other failure still fails the function.
  • _trusted_json_jq, which only existed for this, is removed.
  • README and the protocol skill say what the minimum gh is. A changeset is included.

One behaviour change

issue_for_pr now prints the issue numbers in numeric order (3 15 16), where it sorted them as strings (15 16 3). Nothing in the skills depends on the order.

Verified

  • Against the real gh (2.63.2) on this repository, read-only: prs_for_issue 87 gives 92 MERGED, prs_for_issue 86 gives 90 MERGED, issue_for_pr 92 gives 87, issue_for_pr 91 gives 69, and issue_for_pr 999999 fails with exit 1. The old functions fail on the same gh with Unknown JSON field: "authorAssociation". My gh is older than 2.72, so this exercised the fallback path. The 2.72+ path is covered by the stub tests.
  • The tests fail on the bug. I ran the new tests/lib.test.sh against the old lib.sh: 16 checks fail. The stub now refuses authorAssociation as a PR field the way gh does, serves the REST endpoints with paging, and has new checks for a MEMBER's marker, GitHub's own links joined with the description, an old gh, a missing PR, a PR on the second page, and a PR past the 200 newest.
  • npm run check passes: 177 shell tests (168 before), 435 node tests.

This is the fix #88 was waiting on: once the stub is replaced by the simulator, which rejects unknown --json fields, these two functions no longer break it.

They asked gh pr list and gh pr view for authorAssociation, which is not a PR
field in any gh release, so both failed with 'Unknown JSON field'. They now read
the REST pull request, which has author_association and user.login, and apply
the same trust rule through trusted_jq. issue_for_pr reads GitHub's own issue
links with gh 2.72 or newer and still reads the description without it.

Co-authored-by: Claude <noreply@anthropic.com>
@glennfaison
glennfaison merged commit b563fd8 into main Nov 10, 2026
2 checks passed
@glennfaison
glennfaison deleted the fix/89-pr-author-association branch November 10, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant