Skip to content

bug: github external auth intermittently fails to refresh token #17069

@valeneiko

Description

@valeneiko

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Occasionally when running a git command in workspace a user is prompted to re-authenticate with GitHub, but when they try, they get Failed to validate oauth access token error. From the logs it seems that token refresh request times out. The issue fixes itself after about 10-15 minutes, but clicking login or unlinking and reenabling external auth does not seem to help. Only small number of users are affected.

Image

Additionally, when they go to Account settings in Coder they see a similar token failed to validate error:

Image

Relevant Log Output

2025-03-24 09:43:35.035 [warn]  coderd: GET  host=coder.example.org  path=/api/v2/workspaceagents/me/external-auth  proto=HTTP/1.1  remote_addr=X.X.X.X  start="2025-03-24T09:43:34.876944956Z"  took=158.437119ms  status_code=500  latency_ms=158  response_body="{\"message\":\"Fail
ed to refresh external auth token.\",\"detail\":\"validate external auth token: Get \\\"https://api.github.com/user\\\": context canceled\"}\n"  request_id=f0f95513-5235-4f20-ba1e-b301dd87794a

Expected Behavior

No response

Steps to Reproduce

We have not found what causes the issue initially. But after it happens any of the below commands stop returning access token for the next 10-15 minutes:

GIT_PREFIX= coder "Username for https://github.com/:"
curl -X GET "$CODER_AGENT_URL"'/api/v2/workspaceagents/me/external-auth?match=github.com'   -H 'Accept: application/json'   -H "Coder-Session-Token: $CODER_AGENT_TOKEN"

Environment

  • Host OS: Ubuntu 24.04.2 LTS
  • Coder version: v2.19.0+2f32b11

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    s2Broken use cases or features (with a workaround). Only humans may set this.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions