Repository navigation
fix(github): use the GraphQL endpoint on GitHub Enterprise Server - #4272
Merged
IsmaelMartinez merged 1 commit intoOct 23, 2026
Conversation
resolve_comment_thread() and fetch_sub_issues() posted their GraphQL documents to the relative path "/graphql". PyGithub resolves a relative path under the REST prefix of base_url, so with an Enterprise Server base URL such as https://github.mycompany.com/api/v3 both requests went to /api/v3/graphql rather than /api/graphql. The thread lookup in the same resolve call already reaches /api/graphql through graphql_query(). On GHES, /ask_line thread resolution therefore failed with a "possible permission issue" warning, and ticket analysis never added the sub-issues of a linked issue. Send both requests to the requester's graphql_url, the endpoint PyGithub derives from base_url, through a small _post_graphql() helper. The request path on github.com is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
⚙️ Agent run details
|
IsmaelMartinez
approved these changes
Oct 23, 2026
IsmaelMartinez
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for tracking the Enterprise Server failures down to the relative "/graphql" path and covering both github.com and GHES with tests that drive a real client; this is good to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
What
pr_agent/git_providers/github_provider.py: the two raw GraphQL calls, theresolveReviewThreadmutation inresolve_comment_thread()and the sub-issues query infetch_sub_issues(), now go through a small_post_graphql()helper. It POSTs to the requester'sgraphql_urlinstead of the relative path"/graphql". On github.com the request is unchanged.tests/unittest/test_github_graphql_endpoint.py: 4 new tests (2 functions, each for github.com and Enterprise Server). They drive a real PyGithub client over a stubbedrequests.Sessionthat serves GraphQL only at the documented endpoint, and assert the paths sent and the result. The fake requesters in three existing test files gained thegraphql_urlattribute that PyGithub'sRequesterhas.Why
PyGithub resolves a relative URL under the REST prefix of
base_url. With the documented Enterprise Server settingGITHUB__BASE_URL=https://github.mycompany.com/api/v3(docs/docs/installation/github.md),requestJson("POST", "/graphql")goes to/api/v3/graphql. GHES serves GraphQL at/api/graphql. That is the URL PyGithub'sgraphql_urlderives frombase_url(PyGithub/PyGithub#2880), and_review_thread_nodes()already reaches it throughgraphql_query().So on GHES, within one
resolve_comment_thread()call, the thread lookup reaches/api/graphqlbut the mutation goes to/api/v3/graphql. Reproduced onmainwith a realGithub(base_url="https://github.mycompany.com/api/v3")client (PyGithub 2.10.0, the locked version), over a stub that serves GraphQL only at/api/graphql:The only log output is
Issue ID not found for ...andResolve mutation returned isResolved=false for thread PRRT_1 — possible permission issue. For GHES users this means:/ask_linewithpr_questions.resolve_threads = truenever resolves a thread, and the warning points at permissions.pr_reviewer.require_ticket_analysis_review, on by default) never adds the sub-issues of a linked issue.With this branch the same script returns the sub-issue and
True, and every GraphQL request goes to/api/graphql.The calls keep
requestJsonrather than switching tographql_query().graphql_query()raises on anyerrorsentry, andfetch_sub_issues()handles the NOT_FOUND payload for PR-number links without a traceback on purpose (TestFetchSubIssuesNullGraphQLFields).Testing
PYTHONPATH=. uv run pytest tests/unittest/test_github_graphql_endpoint.py -q: 4 passed. With only thegithub_provider.pychange reverted: 2 failed (both Enterprise Server cases), 2 passed (github.com).PYTHONPATH=. uv run pytest tests/unittest/test_github_provider_comments.py tests/unittest/test_ticket_extraction_async.py tests/unittest/test_github_provider_exception_narrowing.py -q: 241 passed, both on this branch and with the fix reverted, so the fake changes do not alter what those tests check.PYTHONPATH=. uv run pytest tests/unittest -q: 14134 passed, 33 skipped. The other 46 failures and 1 error come from my offline sandbox, mostly tiktoken failing to download its encoding. Unmodifiedmainfails the same 47 tests there, and none of them is a GitHub provider test.uv run ruff checkon the five changed files: All checks passed. The pre-commit-hooks v6.0.0 checks from.pre-commit-config.yamlalso pass on them.All HTTP is stubbed; this was not run against a live GHES instance.
🤖 Generated with Claude Code
PR Type
Bug fix, Tests
Description
Route GraphQL requests through PyGithub's derived endpoint.
Fix Enterprise thread resolution and sub-issue retrieval.
Test endpoint routing across GitHub deployment types.
Update existing requester mocks for endpoint compatibility.
Diagram Walkthrough
File Walkthrough
github_provider.py
Route GraphQL calls through the derived endpointpr_agent/git_providers/github_provider.py
_post_graphql()to send documents to the requester's derivedgraphql_url.helper.
/graphqlto Enterprise Server's RESTprefix.
test_github_graphql_endpoint.py
Verify GraphQL routing across GitHub deployment typestests/unittest/test_github_graphql_endpoint.py
Server.
requests.Session.and thread resolution.
test_github_provider_comments.py
Align comment requester mock with PyGithub endpointstests/unittest/test_github_provider_comments.py
graphql_urlto the fake requester.graphql_query()implementation.
test_github_provider_exception_narrowing.py
Update malformed GraphQL payload requester fixturetests/unittest/test_github_provider_exception_narrowing.py
graphql_urlin the malformed-payload test requester.test_ticket_extraction_async.py
Add GraphQL endpoint to ticket requester mocktests/unittest/test_ticket_extraction_async.py
graphql_urlto the fake requester used for sub-issue null-valuescenarios.
⚙️ Agent run details