Skip to content

Regression: OAuth validation breaks multiline engine.env.COPILOT_GITHUB_TOKEN #47142

Description

@PureWeen

Summary

Multiline engine.env.COPILOT_GITHUB_TOKEN expressions again compile to invalid workflow YAML.

Version testing:

Version Result
v0.82.4 Compiles
v0.82.5 Fails
v0.82.14 Fails
v0.82.15 prerelease Fails
Current public main Fails

This is a regression of #30204 / #30240, introduced through the OAuth-token validation path added by #44204.

Minimal reproduction

---
on:
  workflow_dispatch:
engine:
  id: copilot
  env:
    COPILOT_GITHUB_TOKEN: >-
      ${{ secrets.EXAMPLE_TOKEN_A != '' && secrets.EXAMPLE_TOKEN_A ||
          secrets.EXAMPLE_TOKEN_B != '' && secrets.EXAMPLE_TOKEN_B ||
          secrets.EXAMPLE_TOKEN_C }}
---

Reproduce.

Compile it:

gh aw compile reproduce --approve

Actual result

Compilation fails while validating the generated lock file:

generated lock file is not valid YAML: non-map value is specified
...
env:
  COPILOT_GITHUB_TOKEN: ${{ secrets.EXAMPLE_TOKEN_A != '' && secrets.EXAMPLE_TOKEN_A ||
secrets.EXAMPLE_TOKEN_B != '' && secrets.EXAMPLE_TOKEN_B ||

The continuation lines are emitted without YAML block-scalar indentation in the generated Check for OAuth tokens activation step.

Expected result

Compilation succeeds, and every generated use of the multiline environment value is emitted as a properly indented YAML block scalar.

Root cause

#30240 introduced appendEnvVarLine in pkg/workflow/engine_helpers.go to correctly emit multiline engine.env values.

The OAuth check added by #44204 uses a separate emission path in pkg/workflow/compiler_activation_steps.go:

ctx.steps = append(ctx.steps, fmt.Sprintf("          %s: %s\n", constants.CopilotGitHubToken, copilotTokenExpr))

That bypasses appendEnvVarLine, while existing secret-validation and engine-execution paths continue to emit the value correctly.

Workaround

Place the entire COPILOT_GITHUB_TOKEN expression on one line.

Agentic implementation plan

  1. Update the OAuth validation step in pkg/workflow/compiler_activation_steps.go to emit COPILOT_GITHUB_TOKEN through appendEnvVarLine rather than inline fmt.Sprintf.
  2. Preserve the activation step's current indentation and newline conventions.
  3. Add a multiline override test to pkg/workflow/compiler_activation_jobs_test.go that verifies a valid literal block scalar in the OAuth step.
  4. Add end-to-end compile coverage for multiline values written with both | and >-.
  5. Confirm existing single-line expressions remain emitted inline without behavior changes.

References: #30204, #30240, #44204.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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