Skip to content

Fix: Apply client timeout to Auth requests - #332

Merged
yanyongyu merged 7 commits into
masterfrom
copilot/fix-client-timeout-issue
Oct 25, 2026
Merged

yanyongyu merged 7 commits into
masterfrom
copilot/fix-client-timeout-issue

Conversation

Copilot AI commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

AppInstallationAuthStrategy yields a fresh httpx.Request for the token exchange. httpx only sets the timeout extension on the request passed to send(), not on requests an Auth flow yields. The token request therefore went out with no timeout, and the first call on a client (and every token refresh) could hang indefinitely.

  • githubkit/auth/app.py
    • _build_installation_auth_request now takes the incoming request and copies its extensions onto the token request.
    • sync_auth_flow and async_auth_flow pass the incoming request through.
gh = GitHub(AppInstallationAuthStrategy(1, key, 2), timeout=5, ...)
gh.rest.users.get_by_username("x")
# before: POST /app/installations/2/access_tokens -> timeout=None
# after:  POST /app/installations/2/access_tokens -> {'connect': 5, 'read': 5, 'write': 5, 'pool': 5}

Review notes:

  • Approach: the issue suggested client.build_request. I copied the incoming request's extensions instead, because the auth flow has no client reference. That also carries over any other per-request extensions, not just timeout.
  • Not covered: the OAuth token-exchange requests in auth/oauth.py build bare httpx.Requests too. Those helpers are also used outside an httpx auth flow, where there is no incoming request to copy from, so I left them alone.
  • Tests: none added or run.

Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix app installation token request to respect client timeout Apply client timeout to App installation token request Oct 25, 2026
Copilot AI requested a review from yanyongyu October 25, 2026 10:59
Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
@yanyongyu

Copy link
Copy Markdown
Owner

pre-commit.ci autofix

@yanyongyu
yanyongyu marked this pull request as ready for review October 25, 2026 11:15
@yanyongyu yanyongyu added the bug Something isn't working label Oct 25, 2026
@yanyongyu yanyongyu changed the title Apply client timeout to App installation token request Fix: Apply client timeout to Auth requests Oct 25, 2026
Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
@yanyongyu
yanyongyu merged commit 457b007 into master Oct 25, 2026
38 checks passed
@yanyongyu
yanyongyu deleted the copilot/fix-client-timeout-issue branch October 25, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: the App installation token request ignores the client timeout

2 participants