Skip to content

Environment variables set in workflow step env block are not passed to Claude Code subprocess #887

@csy1204

Description

@csy1204

Describe the bug

When users set OpenTelemetry or other environment variables in the workflow step's env: block, these variables are not passed to the Claude Code subprocess. This is because GitHub Actions composite actions only forward environment variables that are explicitly referenced in the action's internal env: block using ${{ env.VAR_NAME }} syntax.

To Reproduce

  1. Create a workflow with OpenTelemetry configuration:
- name: Run Claude Code
  uses: anthropics/claude-code-action@v1
  env:
    CLAUDE_CODE_ENABLE_TELEMETRY: "1"
    OTEL_METRICS_EXPORTER: "otlp"
    OTEL_LOGS_EXPORTER: "otlp"
    OTEL_EXPORTER_OTLP_PROTOCOL: "http/json"
    OTEL_EXPORTER_OTLP_ENDPOINT: "https://my-otel-collector.example.com"
    OTEL_METRIC_EXPORT_INTERVAL: "10000"
    OTEL_LOGS_EXPORT_INTERVAL: "5000"
    OTEL_RESOURCE_ATTRIBUTES: "department=myteam"
  with:
    prompt: "Hello"
  1. Run the workflow
  2. Check your OTEL collector - no telemetry data is received

Expected behavior

Environment variables set in the step's env: block should be passed to the Claude Code subprocess, allowing users to configure custom telemetry endpoints.

Screenshots

N/A

Workflow yml file

See reproduction steps above.

API Provider

  • Anthropic First-Party API (default)
  • AWS Bedrock
  • GCP Vertex

(This affects all providers)

Additional context

Root Cause Analysis:

In action.yml and base-action/action.yml, the "Run Claude Code Action" step explicitly lists environment variables to pass:

env:
  ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
  AWS_REGION: ${{ env.AWS_REGION }}
  # ... other vars explicitly listed

Since OTEL_* and CLAUDE_CODE_ENABLE_TELEMETRY variables were not listed, they are silently dropped by the composite action runner, even when set in the workflow.

Verified locally:

  • SDK correctly passes env vars to subprocess when explicitly provided via sdkOptions.env
  • The issue is specifically in the composite action's env forwarding

Fix: PR #886 adds explicit references for telemetry-related environment variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:installationbugSomething isn't workingp2Non-showstopper bug or popular feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions