Skip to content

bug: environment variables in sandbox.agent.mounts are not expanded at runtime #37724

@yskopets

Description

@yskopets

🤖 This issue has been filed by Claude Code on behalf of a user.

Summary

When using environment variables in sandbox.agent.mounts, the compiled output wraps the mount spec in single quotes, which prevents shell expansion at runtime. The variable is passed literally to awf, which then rejects it because the host path does not start with /.

Steps to reproduce

Add a mount that references an environment variable set by a preceding step:

sandbox:
  agent:
    mounts:
      - ${TERRAFORM_CLI_PATH}/terraform:${TERRAFORM_CLI_PATH}/terraform:ro

steps:
  - name: Set up Terraform
    uses: hashicorp/setup-terraform@...

Compile and run the workflow. The Execute Claude Code CLI step fails with:

[ERROR] Invalid volume mount: ${TERRAFORM_CLI_PATH}/terraform:${TERRAFORM_CLI_PATH}/terraform:ro
[ERROR] Reason: Host path must be absolute (start with /)

Root cause

The compiled lock file emits the mount flag wrapped in single quotes:

--mount '${TERRAFORM_CLI_PATH}/terraform:${TERRAFORM_CLI_PATH}/terraform:ro'

Single quotes suppress all shell expansion, so ${TERRAFORM_CLI_PATH} is never resolved to its actual value (e.g. /home/runner/work/_temp/fa43a6e6-.../). The awf binary receives the literal string and rejects it.

Expected behavior

Either:

  • The compiler uses double quotes so the shell expands the variable at runtime, or
  • The compiler resolves/interpolates env vars from earlier steps at compile time, or
  • The documentation calls out that only literal paths are supported in mounts and suggests a workaround

Workaround

Resolve the variable in a preceding step and copy the binary to a known absolute path, then reference that path in the mount spec:

sandbox:
  agent:
    mounts:
      - /usr/local/bin/terraform:/usr/local/bin/terraform:ro   # absolute path, no variables

steps:
  - name: Set up Terraform
    uses: hashicorp/setup-terraform@...

  - name: Copy terraform binary to absolute path for container mount
    run: cp "$(which terraform)" /usr/local/bin/terraform

Environment

  • gh aw compile version: v0.77.5 (from compiled lock manifest)
  • awf container image: ghcr.io/github/gh-aw-firewall/agent:0.25.58

Metadata

Metadata

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