Skip to content

fix(workspace): look up provider tokens as GITHUB_TOKEN - #5730

Draft
jpshackelford wants to merge 3 commits into
mainfrom
fix/provider-token-env-var-names
Draft

jpshackelford wants to merge 3 commits into
mainfrom
fix/provider-token-env-var-names

Conversation

@jpshackelford

@jpshackelford jpshackelford commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

This PR is part of agentic self-healing work for the SDK.


AGENT:

Why

clone_repos requested the provider token as github_token, gitlab_token or bitbucket_token. Everywhere else, including OpenHands conversations, the GitHub skill and the plugin-source docs, the same token is GITHUB_TOKEN. Secret names are case-sensitive. When a user stored their token under the documented name, clone_repos ran git clone without credentials, so their private repos failed to clone.

Summary

  • PROVIDER_TOKEN_NAMES maps providers to GITHUB_TOKEN, GITLAB_TOKEN and BITBUCKET_TOKEN.
  • clone_repos falls back to the lowercase name when the uppercase one has no value, because app servers before fix: name provider tokens GITHUB_TOKEN in sandbox secrets endpoints enterprise#752 serve only the lowercase name.
  • The agent server's GitHub token candidates keep github_token, so its lookup is unchanged. The verify-agent-server feature maps (F15, F18) now use the new names.

Issue Number

Fixes #5729

How to Test

Run uv run pytest tests/workspace/test_cloud_workspace_repos.py.

  • test_clone_authenticates_with_token_stored_under_env_var_name stores the token as GITHUB_TOKEN, GITLAB_TOKEN or BITBUCKET_TOKEN and checks that it reaches the clone command.
  • test_clone_falls_back_to_lowercase_token_name checks the lookup order (uppercase, then lowercase) and that a token served only as github_token is still used.
  • test_clone_prefers_uppercase_token_name checks that the uppercase token wins when both names exist.

I also ran the real clone_repos with a real 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). The token was stored only as GITHUB_TOKEN.

Token names requested Result
main (acca181) ['github_token'] fatal: could not read Username for 'https://github.com', 0/1 cloned
this branch ['GITHUB_TOKEN'] 1/1 cloned

Video/Screenshots

None.

Design Doc

None.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

RepoSource.get_token_name() now returns the uppercase name, which callers outside clone_repos will see. Once the enterprise change is deployed everywhere, the lowercase fallback can be removed.


This PR was drafted by an AI agent (OpenHands) on behalf of @jpshackelford.


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:1190075-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-1190075-python \
  ghcr.io/openhands/agent-server:1190075-python

All tags pushed for this build

ghcr.io/openhands/agent-server:1190075-golang-amd64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-golang-amd64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-golang-amd64
ghcr.io/openhands/agent-server:1190075-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:1190075-golang-arm64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-golang-arm64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-golang-arm64
ghcr.io/openhands/agent-server:1190075-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:1190075-java-amd64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-java-amd64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-java-amd64
ghcr.io/openhands/agent-server:1190075-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:1190075-java-arm64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-java-arm64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-java-arm64
ghcr.io/openhands/agent-server:1190075-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:1190075-python-amd64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-amd64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-amd64
ghcr.io/openhands/agent-server:1190075-python-node-runtime-amd64
ghcr.io/openhands/agent-server:1190075-python-arm64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-arm64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-arm64
ghcr.io/openhands/agent-server:1190075-python-node-runtime-arm64
ghcr.io/openhands/agent-server:1190075-python-minimal-amd64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-minimal-amd64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-minimal-amd64
ghcr.io/openhands/agent-server:1190075-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:1190075-python-minimal-arm64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-minimal-arm64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-minimal-arm64
ghcr.io/openhands/agent-server:1190075-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:1190075-python-slim-amd64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-slim-amd64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-slim-amd64
ghcr.io/openhands/agent-server:1190075-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:1190075-python-slim-arm64
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-slim-arm64
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-slim-arm64
ghcr.io/openhands/agent-server:1190075-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:1190075-golang
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-golang
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-golang
ghcr.io/openhands/agent-server:1190075-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:1190075-java
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-java
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-java
ghcr.io/openhands/agent-server:1190075-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:1190075-python-minimal
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-minimal
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-minimal
ghcr.io/openhands/agent-server:1190075-python-node-runtime-minimal
ghcr.io/openhands/agent-server:1190075-python-slim
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python-slim
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python-slim
ghcr.io/openhands/agent-server:1190075-python-node-runtime-slim
ghcr.io/openhands/agent-server:1190075-python
ghcr.io/openhands/agent-server:11900752af042b2da55401bad15e18f85ead0ca9-python
ghcr.io/openhands/agent-server:fix-provider-token-env-var-names-python
ghcr.io/openhands/agent-server:1190075-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 1190075-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 1190075-python-amd64) are also available if needed

clone_repos requested github_token, gitlab_token and bitbucket_token, so a
token stored under its conventional env var name was never used and private
repos were cloned without credentials. It now requests GITHUB_TOKEN etc. and
falls back to the lowercase name served by older app servers.

Fixes #5729

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   git_provider_service.py1151290%64, 83–87, 171–173, 187, 204, 208
openhands-sdk/openhands/sdk/workspace
   repo.py25516635%70–75, 80, 101–103, 105–110, 177, 180, 184, 188, 200–201, 205–207, 212, 216–217, 219–221, 224, 228, 252–254, 269, 272–273, 276–277, 280, 283–284, 293, 295, 297, 310–311, 314–317, 343–345, 347–348, 351–353, 355–356, 358–362, 365, 368–370, 373, 375–376, 386–387, 389–393, 405, 411–412, 414–416, 421–423, 426–427, 429–430, 432–433, 435, 437–438, 441–443, 445–446, 449, 452–454, 456–457, 464–465, 469, 472–474, 477–480, 499–501, 504–511, 515–517, 519–520, 522–525, 527–531, 534–537, 540–542, 544–545, 547–548, 555–556, 558–560, 562–564, 566
openhands-workspace/openhands/workspace/cloud
   workspace.py39010274%216–218, 289, 308, 311–313, 316, 322, 324–326, 348, 351, 356, 358–359, 361–363, 365, 367–368, 371–374, 376–377, 379–380, 382, 384–386, 389–390, 394–405, 410, 479–480, 495–496, 501, 530–532, 781, 834–835, 878–879, 882–884, 887, 893–894, 898–903, 905–909, 972, 981–983, 986, 992–994, 999–1000, 1002–1012
TOTAL46056512189% 

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

Copy link
Copy Markdown
Contributor

📁 PR Artifacts Notice

This PR contains a .pr/ directory with temporary PR-specific documents. The directory will be automatically removed after this PR merges to main through a cleanup PR.

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]: PROVIDER_TOKEN_NAMES uses github_token instead of GITHUB_TOKEN

3 participants