Skip to content

[awf] cli/docker-manager: gh pr checkout fails when GH_HOST inherits proxy value in agent environment #1496

@lpcox

Description

@lpcox

Problem

When AWF runs in a proxied / DIFC-style environment, GH_HOST may be set on the runner host to point at a local proxy (e.g. localhost:8080 or similar). Because AWF's --env-all path (src/docker-manager.ts) copies unfiltered host environment variables into the agent container, GH_HOST is inherited by the agent.

Inside the agent, any gh pr checkout step (either user-authored or emitted by the gh-aw compiler) then fails with:

none of the git remotes configured for this repository correspond to the GH_HOST environment variable

This is because git remotes still reference the real GitHub hostname while GH_HOST is pointing at the proxy. The workflow fails before the agent begins its primary task.

Context

Root Cause

Two compounding factors:

  1. src/docker-manager.ts — env-all inheritance (generateDockerCompose, env-building logic around line 494–510): GH_HOST is not in EXCLUDED_ENV_VARS, so it flows through --env-all directly into the agent container, carrying whatever proxy-scoped value the host setup left behind.

  2. Compiled PR checkout step (generated lock-file YAML / gh-aw compiler): The emitted gh pr checkout step runs with the ambient job-level GH_HOST, with no step-level override to restore the canonical host before checkout.

Proposed Solution

Short-term (AWF firewall env normalization)

In src/docker-manager.ts, add GH_HOST to the list of environment variables that are overridden (not just excluded) from --env-all, and set it to the canonical value derived from GITHUB_SERVER_URL:

// After env-all merging, normalize GH_HOST to canonical GitHub host
if (process.env.GITHUB_SERVER_URL) {
  const canonicalHost = new URL(process.env.GITHUB_SERVER_URL).hostname;
  agentEnv['GH_HOST'] = canonicalHost;
}

This ensures the agent always sees a GH_HOST that matches its git remotes, regardless of what the outer DIFC/proxy setup set.

Medium-term (compiler-level fix)

In the gh-aw workflow compiler, scope GH_HOST (and related GITHUB_API_URL, GITHUB_GRAPHQL_URL) to their canonical values in the emitted gh pr checkout step's env: block, so the fix is baked into compiled lock files independently of the AWF runtime.

Long-term (git-native checkout for same-repo PRs)

For same-repository PR heads, use deterministic git fetch + git checkout of the head ref instead of gh pr checkout. Reserve gh pr checkout for cross-repo / fork cases where it is necessary.

Tests / validation

Add a unit test in src/docker-manager.test.ts (or integration test) that sets GH_HOST=localhost:8080 in the process environment, calls generateDockerCompose, and asserts the resulting agent env contains the canonical GH_HOST (not localhost:8080).

Generated by Firewall Issue Dispatcher ·

Metadata

Metadata

Assignees

No one assigned

    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