Skip to content

'malformed version' for all gh commands in user steps using explicit --repo  #35264

@dsyme

Description

@dsyme

Summary

start_difc_proxy.sh writes GH_HOST=localhost:18443 to $GITHUB_ENV, which persists to all subsequent steps in the job. Any gh CLI command in a user-defined steps: block that uses an explicit --repo flag then treats the DIFC proxy as a GitHub Enterprise Server, attempts an enterprise version check against it, receives an empty version string, and exits with:

malformed version: 

This crashes the step before any real work is done.

Affected scope

gh commands with an explicit --repo owner/repo flag in user-defined steps: that run after "Start DIFC Proxy". Commands that omit --repo (relying on GITHUB_REPOSITORY) appear to be unaffected — gh uses GITHUB_API_URL directly in that case and skips the host version check.

Comparison: A comparable workflow on fsprojects/FSharp.Data using the same gh-aw v0.76.1 does NOT reproduce this. Its steps: use gh issue list --state open ... and gh pr list --state open ... without --repo, which succeed fine even with GH_HOST=localhost:18443 in the environment.

Reproduction

Add a gh command with --repo to a steps: block in a workflow that starts the DIFC proxy:

steps:
  - name: Fetch data
    env:
      GH_TOKEN: ${{ secrets.MY_PAT }}
    run: |
      gh issue list --repo owner/other-repo --json number,title > /tmp/issues.json

The step immediately fails with malformed version: because GH_HOST=localhost:18443 (written to $GITHUB_ENV by start_difc_proxy.sh) causes gh to attempt a GHES enterprise version check against the proxy before making any API call.

Root cause

start_difc_proxy.sh contains something equivalent to:

echo "GH_HOST=localhost:18443" >> "$GITHUB_ENV"

This sets GH_HOST for the rest of the job. The gh CLI treats any non-github.com value for GH_HOST as a GitHub Enterprise Server hostname and performs a version validation before API calls made with --repo. The DIFC proxy doesn't implement the GHES version endpoint, so it returns an empty string, which gh rejects as malformed version: .

Workaround

Override GH_HOST at the shell level at the top of the run: script:

GH_HOST=github.com  # override proxy-injected GH_HOST; API traffic still routes
                    # through the proxy via GITHUB_API_URL / GITHUB_GRAPHQL_URL
gh issue list --repo owner/other-repo ...

Note: a step-level env: GH_HOST: github.com in the gh-aw source file has no effect because the gh-aw compiler does not preserve user-defined step env: blocks in the compiled lock file. The override must be inside the run: script.

Expected behaviour

User-defined steps: should be able to use gh --repo commands without a workaround. Either:

  • start_difc_proxy.sh should not write GH_HOST to $GITHUB_ENV (or should write GH_HOST=github.com), relying on GITHUB_API_URL / GITHUB_GRAPHQL_URL to route API traffic through the proxy, or
  • The proxy setup should configure gh in a way that doesn't require GH_HOST to point at the proxy address for routing to work

Environment

  • gh-aw compiler version: v0.76.1
  • gh CLI version: 2.79.0
  • DIFC proxy image: ghcr.io/github/gh-aw-mcpg:v0.3.19

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions