Skip to content

Terminal: saved GITHUB_TOKEN/GITLAB_TOKEN secret is not used by git or gh unless the command names it #6814

Open

Description

@neubig

Summary

A git provider token saved as a conversation secret (GITHUB_TOKEN, GH_TOKEN, GITLAB_TOKEN) is not used by the agent's git or gh commands. The terminal exports a registered secret only when the command text names it (SecretRegistry.get_secrets_as_env_vars → find_secrets_in_text), and nothing configures git to use the token. A plain git push therefore fails with could not read Username for 'https://github.com', and gh reports it is not logged in. The agent can only work around this by naming the secret, typically by embedding the token in the remote URL, which writes it to .git/config.

Downstream report: OpenHands/OpenHands#18847 (Agent Canvas, Docker, PAT saved in Settings → Secrets).

Acceptance criteria

  • When a GITHUB_TOKEN (or GH_TOKEN) secret is registered, the agent's HTTPS git push / fetch / clone against github.com authenticate with it without the command naming the secret, embedding the token in a URL, or writing it to a git config file.
  • gh commands run by the agent authenticate with the same token.
  • The same works for a GITLAB_TOKEN secret against gitlab.com.
  • The token stays masked in agent-visible output; no global git config is modified; a credential helper the user already configured is consulted first.
  • Commands that do not run git/gh/glab, and conversations without such a secret, behave exactly as today.

Reproduction on main (91e8b5b)

Agent Canvas main against an agent-server installed from this repo's main (91e8b5b68, v1.62.0), fresh HOME, scripted fake LLM. A valid token is saved as GITHUB_TOKEN, then the agent runs git push --dry-run to a github.com remote and gh api: both fail (exit 128 / exit 4).

Secrets settings with GITHUB_TOKEN saved
git push and gh fail although GITHUB_TOKEN is saved

This issue was created by an AI agent (OpenHands) on behalf of Graham Neubig.

Activity

  1. added
    bug
    on Nov 13, 2026
  2. self-assigned this
    on Nov 16, 2026
  3. added
    ready-for-dev
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugready-for-dev

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions