Skip to content

[Bug]: PROVIDER_TOKEN_NAMES uses github_token instead of GITHUB_TOKEN #5729

Closed

Description

@jpshackelford

Is there an existing issue for the same bug?

  • I have searched existing issues and this is not a duplicate.

Bug Description

PROVIDER_TOKEN_NAMES in openhands/sdk/workspace/repo.py L46–L50 names git provider tokens github_token, gitlab_token and bitbucket_token. RemoteWorkspace.clone_repos() / OpenHandsCloudWorkspace.clone_repos() request the token under that name through _get_secret_value().

Elsewhere in the OpenHands ecosystem, the same credential is called GITHUB_TOKEN:

  • Enterprise conversations receive GITHUB_TOKEN.
  • OVERRIDABLE_SYSTEM_SECRETS and tokenEnvVar in the app server use GITHUB_TOKEN.
  • The GitHub skill tells agents to use GITHUB_TOKEN.
  • The enterprise-cookbook documents ${GITHUB_TOKEN} for private plugin sources.

The only server-side match for the lowercase name is the Cloud sandbox secrets endpoint, which is tracked as a bug in OpenHands/enterprise#750. The agent server's git_provider_service.py L26–L31 already accepts both names (github_token, GITHUB_TOKEN, GH_TOKEN, github).

Secret names are case-sensitive throughout, so github_token and GITHUB_TOKEN are different secrets. Because of that, the token for a user's connected GitHub account has a different name depending on which route delivered it.

Expected Behavior

There is one name per provider token (GITHUB_TOKEN, GITLAB_TOKEN, BITBUCKET_TOKEN). clone_repos, ${GITHUB_TOKEN} expansion in plugin sources, and the agent's shell environment all use it.

Actual Behavior

  • clone_repos uses github_token.
  • On Cloud, clone_repos works only because the sandbox endpoint also uses the lowercase name.
  • On a local agent server, when a user stores their token under the documented name GITHUB_TOKEN, clone_repos clones without credentials and private repos fail to clone. This is demonstrated below.

Steps to Reproduce

  1. Start a RemoteWorkspace against an agent server that has a secret named GITHUB_TOKEN and none named github_token.
  2. Call workspace.clone_repos(["https://github.com/<owner>/<private-repo>"]).
  3. clone_repos requests only github_token, gets None, and runs git clone without credentials.

Demonstrated on main (acca181) by running the real clone_repos and git clone against a local bare repo that git could reach only through a token-bearing github.com URL (an insteadOf rewrite, as in recipe F18.sdk-clone-repos):

token names requested: ['github_token']
[clone] Failed: ... fatal: could not read Username for 'https://github.com': terminal prompts disabled
cloned: 0 failed: ['https://github.com/owner/private-repo']

With the fix in #5730, the same run requests GITHUB_TOKEN and clones 1/1. The new unit test test_clone_authenticates_with_token_stored_under_env_var_name fails on main for GitHub, GitLab and Bitbucket and passes with the fix.

Acceptance Criteria

SDK Version

main at acca181 (2026-10-12)


This issue was created by an AI agent (OpenHands) on behalf of @jpshackelford. Found while reviewing private plugin sources for OpenHands/automation#579. Fix: #5730.


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Confirmed against main (acca181): PROVIDER_TOKEN_NAMES in openhands-sdk/openhands/sdk/workspace/repo.py maps each provider to a lowercase secret name (github_token, gitlab_token, bitbucket_token), and RemoteWorkspace.clone_repos() / OpenHandsCloudWorkspace.clone_repos() fetch the token via _get_secret_value(name) -> GET /api/settings/secrets/{name}. Secret names are case-sensitive, and the agent server's own git_provider_service.py already accepts the uppercase names first, so the clone path and the rest of the ecosystem disagree on the name. This repository owns the fix; the Cloud sandbox endpoint that still serves the lowercase name is tracked separately in OpenHands/enterprise#750.

Scope: rename the three provider token names to GITHUB_TOKEN / GITLAB_TOKEN / BITBUCKET_TOKEN, and keep clone_repos working against servers that only have the lowercase secret by falling back to it.

Non-goals: changing the Cloud sandbox secrets endpoint (enterprise#750); renaming or case-normalizing any custom secret; changing the agent-server /api/settings/secrets contract or its secret-name validation.

Acceptance Criteria

  • PROVIDER_TOKEN_NAMES maps GitProvider.GITHUB, GITLAB, and BITBUCKET to GITHUB_TOKEN, GITLAB_TOKEN, and BITBUCKET_TOKEN respectively, and RepoSource.get_token_name() returns those values.
  • With only the uppercase secret stored on an agent server, RemoteWorkspace.clone_repos() and OpenHandsCloudWorkspace.clone_repos() fetch it and authenticate the clone (_get_secret_value("GITHUB_TOKEN") returns the stored value).
  • Backward compatibility: when only the lowercase secret (e.g. github_token) exists, clone_repos still authenticates by falling back to that name; when both exist, the uppercase name takes precedence.
  • When neither name exists, behavior is unchanged: _get_secret_value returns None (404) and the clone proceeds unauthenticated.
  • The agent-server GitHub token resolution in git_provider_service.py still resolves a stored token, and its candidate list is not left with a duplicated first entry after the rename.
  • Custom secret names and their case are unchanged; only the three provider token names are affected.
  • Credential redaction is not regressed: a failing clone whose stderr echoes the token still redacts it in the logs.
  • Docstrings and the verify-agent-server feature-map references that name the lowercase token for clone_repos (F15, F18) reflect the new uppercase name.
  • Existing tests asserting the old lowercase token names are updated, and a test covers the lowercase fallback.

Activity

  1. added
    bug
    on Oct 12, 2026
  2. added
    ready-for-dev
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions