Skip to content

Output path is JSON or file path? #1876

@yaananth

Description

@yaananth

I think some regression or someting..not sure..cannot create discussions

echo "GITHUB_AW_AGENT_OUTPUT=/tmp/gh-aw/safe-outputs/agent_output.json" >> $GITHUB_ENV

but we expect it to be JSON content not file path?

const outputContent = process.env.GITHUB_AW_AGENT_OUTPUT;
              if (!outputContent) {
                core.info("No GITHUB_AW_AGENT_OUTPUT environment variable found");
                return;
              }
              if (outputContent.trim() === "") {
                core.info("Agent output content is empty");
                return;
              }
              core.info(`Agent output content length: ${outputContent.length}`);
              let validatedOutput;
              try {
                validatedOutput = JSON.parse(outputContent);

I get

Run actions/github-script@v8
Agent output content length: 41
Error: Error parsing agent output JSON: Unexpected token '/', "/tmp/gh-aw"... is not valid JSON`

copilot response

 I dug through githubnext/gh-aw and found the regression.

  - In v0.22.5 and earlier, safe-output jobs passed the JSON string via GITHUB_AW_AGENT_OUTPUT = ${{ needs.<main>.outputs.output }}. The downstream scripts (e.g. pkg/
    workflow/js/create_discussion.cjs) still expect a JSON blob and immediately call JSON.parse(process.env.GITHUB_AW_AGENT_OUTPUT).
  - Commit 4a874cdf (“Fix empty GITHUB_AW_AGENT_OUTPUT in safe output jobs”, Oct 17 2025) changed pkg/workflow/safe_output_helpers.go (and related lockfiles) so the setup
    step now downloads agent_output.json and sets
    echo "GITHUB_AW_AGENT_OUTPUT=/tmp/gh-aw/safe-outputs/agent_output.json" >> $GITHUB_ENV.
    No accompanying change was made to the JavaScript runners.
  - Result: process.env.GITHUB_AW_AGENT_OUTPUT now holds a file path, not JSON, so every safe-output script throws (“Unexpected token '/' …”) when it tries to parse it.

  How to fix in the CLI:

  1. Revisit that 4a874cdf change. Either:
      - Revert to exporting the JSON string (core.exportVariable("GITHUB_AW_AGENT_OUTPUT", JSON.stringify(validatedOutput))) while still uploading the artifact, or
      - Update every safe-output GitHub Script (create_discussion, create_issue, etc.) to detect when the env var points to an existing file and fs.readFileSync it before
        parsing.
  2. Once you pick the approach, add/update regression tests (see pkg/workflow/js/create_discussion.test.cjs and pkg/workflow/safe_output_helpers_test.go) so both the
     JSON-string and file-path scenarios are covered and future releases won’t break again.

  Until the upstream CLI is patched, any workflow generated by v0.22.6+ will keep producing a file path, so the runtime runbooks (like ours) must override the env var
  with the JSON string as a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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