Skip to content

Fix: Set all job outputs in collect_ndjson_output.cjs early returns and error paths#15603

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-collect-ndjson-output
Feb 14, 2026
Merged

Fix: Set all job outputs in collect_ndjson_output.cjs early returns and error paths#15603
pelikhan merged 2 commits into
mainfrom
copilot/fix-collect-ndjson-output

Conversation

Copilot AI commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

The collect_ndjson_output.cjs script only set the output job output in early return and error code paths, leaving output_types and has_patch undefined. This caused the detection job condition needs.agent.outputs.output_types != '' to evaluate false, breaking the workflow chain.

Changes

actions/setup/js/collect_ndjson_output.cjs

  • Early returns (no output file, file doesn't exist): Set output_types="" and has_patch="false"
  • Error catch block: Set all outputs before calling setFailed()

actions/setup/js/collect_ndjson_output.test.cjs

  • Added assertions verifying output_types and has_patch are set in early return scenarios

Example

Before:

if (!outputFile) {
  core.setOutput("output", "");
  return;  // output_types and has_patch remain undefined
}

After:

if (!outputFile) {
  core.setOutput("output", "");
  core.setOutput("output_types", "");
  core.setOutput("has_patch", "false");
  return;
}

This ensures downstream jobs can evaluate conditions correctly even when the agent produces no outputs or encounters errors during ingestion.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linu-importcfg (http block)
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linu-nolocalimports 1 1 /var/log/sysstat--show-toplevel 64/pkg/tool/linu/tmp/go-build3162939764/b412/_testmain.go -c 1333162328/.github/workflows .cfg 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha 2939764/b399/_pkg_.a /tmp/go-build3162939764/b201/vet.cfg 2939764/b399=> (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha se 2939764/b048/vet.cfg .cfg (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha .go o x_amd64/vet ath ../../../.prgit b/gh-aw/pkg/giturev-parse _modules/.bin/sh--show-toplevel x_amd64/vet -ato�� Gnbv/0a23WC6_jxwYuk0mGnbv -buildtags /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc 2939764/b388/importcfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha OKEN }} (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha -test.paniconexit0 -test.v=true (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha qbrT4ak5e .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha 2939764/b414/testutil.test -buildtags clusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle -errorsas -ifaceassert -nilfunc 4qBSgoBRlrikz/avxLPGO5v5ZsAOsG8WsF/788KaSlanoh1QIKEP8dB/iAJz33n4qBSgoBRlrikz -C runs/20260214-050203-14833/test-968444793 config 2939764/b414/_pkg_.a s/test.md --global ode_modules/.bin--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha WorkflowFiles_TransitiveImports1761435968/001 -1 /usr/bin/git */*.ts' '**/*.jsgit (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha on' --ignore-path ../../../.prettierignore (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build3162939764/b386/importcfg -pack /tmp/go-build3162939764/b386/_testmain.go conf�� --no-file-parall-errorsas user.email tions/node_modul-nilfunc (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha g/cli /tmp/go-build3162939764/b058/vet.cfg (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: `/usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha g/cli /tmp/go-build3162939764/b010/vet.cfg x_amd64/link ath ../../../.prgit on_output.cjs

Trev-parse sh x_amd64/link t-ha�� ithub/workflows/ai-moderator.md -buildtags /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet l -ifaceassert -nilfunc jN/JBtykRIlcGWOtwYUQjgZ/naM-_mlLtQWiLmcfGX_G` (http block)

  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 origin 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 origin x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 origin x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 origin x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 origin x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 origin x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 origin 64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha tsc --noEmit .cfg 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo ache/go/1.25.0/x-nilfunc (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo de_modules/.bin/-lang=go1.17 (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name (http block)
  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login ACCEPT (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login submodules | head -n 10 (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: collect_ndjson_output.cjs doesn't set job outputs, breaking workflow chain</issue_title>
<issue_description># Bug Report: Agent Job Outputs Not Set, Breaking Workflow Chain

Summary

The collect_ndjson_output.cjs script successfully processes safe outputs but fails to set GitHub Actions job outputs (output_types, has_patch). This breaks the workflow chain, causing detection and safe_outputs jobs to skip, preventing PR comments from being posted.

Environment

Expected Behavior

  1. Agent executes and calls safe output tools (e.g., add_comment)
  2. Safe outputs written to /opt/gh-aw/safeoutputs/outputs.jsonl
  3. Ingest agent output step (using collect_ndjson_output.cjs) processes outputs
  4. Job outputs set: output_types = "add_comment", has_patch = appropriate value
  5. Detection job runs (condition: needs.agent.outputs.output_types != '')
  6. Safe_outputs job runs (condition: needs.detection.outputs.success == 'true')
  7. Comments posted to PR

Actual Behavior

  1. ✅ Agent executes and calls add_comment successfully
  2. ✅ Safe outputs written correctly to outputs.jsonl
  3. Ingest agent output step succeeds (conclusion: success)
  4. Job outputs NOT set - remain empty/undefined
  5. ❌ Detection job skips (condition fails)
  6. ❌ Safe_outputs job skips (detection didn't run)
  7. ❌ Comments never posted

Evidence

Workflow Run Details

Agent Job Status

{
  "name": "agent",
  "conclusion": "failure",
  "outputs": {} // Empty - should contain output_types and has_patch
}

Ingest Agent Output Step

  • Step ID: collect_output
  • Conclusion: success
  • Issue: Step succeeded but didn't set job-level outputs

Safe Outputs File Content

{
  "items": [
    {
      "body": "## 🤖 Automated PR Review: ...",
      "item_number": 80,
      "type": "add_comment"
    }
  ],
  "errors": []
}

Note: The safe outputs file is correctly formatted with type: "add_comment", but output_types job output was not set.

Expected Job Outputs (from workflow line 88-94)

outputs:
  output_types: ${{ steps.collect_output.outputs.output_types }}
  has_patch: ${{ steps.collect_output.outputs.has_patch }}

These should be set by collect_ndjson_output.cjs but remain undefined.

Steps to Reproduce

  1. Create a PR review agent workflow using gh-aw v0.43.23
  2. Configure with Claude engine and safe-outputs (add_comment tool)
  3. Create a pull request to trigger the workflow
  4. Agent executes and calls add_comment successfully
  5. Observe that:
    • Ingest step succeeds
    • Job outputs remain unset
    • Detection and safe_outputs jobs skip

Workflow Configuration

.md source (simplified):

---
on:
  pull_request:
    types: [opened, synchronize, reopened]

engine: claude

safe-outputs:
  add-comment:
    max: 2
---

# PR Review Agent
[Agent instructions to call add_comment with review]

Compiled workflow: https://github.com/otrajman/chichaq/blob/main/.github/workflows/pr-review-agent.lock.yml

Impact

  • Severity: High - Core functionality broken
  • Workaround: Manually download artifacts and post comments
  • Affected: All workflows using safe-outputs with detection enabled

Relevant Workflow Lines

# Line 746-759: Ingest agent output
- name: Ingest agent output
  id: collect_output
  uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
  env:
    GH_AW_SAFE_OUTPUTS: /opt/gh-aw/safeoutputs/outputs.jsonl
  with:
    script: |
      const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs');
      setupGlobals(core, github, context, exec, io);
      const { main } = require('/opt/gh-aw/actions/collect_ndjson_output.cjs');
      await main();

# Line 926-928: Detection job condition
detection:
  needs: agent
  if: needs.agent.outputs.output_types != '' || needs.agent.outputs.has_patch == 'true'

# Line 1063-1067: Safe_outputs job condition
safe_outputs:
  needs:
    - agent
    - detection
  if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (needs.detection.outputs.success == 'true')

Additional Context

  • The collect_ndjson_output.cjs script appears to process the file successfully (step succeeds)
  • However, core.setOutput() is either not being called or outputs aren't propagating to job level
  • This suggests an issue in how the script sets outputs or how gh-aw processes them

Artifacts Available

If helpful for debugging, these artifacts are available from the workflow run:

  • ...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ollect_ndjson_output.cjs

This fixes a bug where job outputs remain undefined when early return
paths are taken (no output file, file doesn't exist) or when errors
occur during ingestion. The detection and safe_outputs jobs depend on
these outputs being defined, so they would skip if outputs were undefined.

Changes:
- Set output_types="" and has_patch="false" in early return paths
- Set all outputs in error catch block before failing
- Add tests to verify outputs are set in early return scenarios

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix collect_ndjson_output.cjs to set job outputs Fix: Set all job outputs in collect_ndjson_output.cjs early returns and error paths Feb 14, 2026
Copilot AI requested a review from pelikhan February 14, 2026 05:05
@pelikhan pelikhan marked this pull request as ready for review February 14, 2026 05:06
Copilot AI review requested due to automatic review settings February 14, 2026 05:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in the collect_ndjson_output.cjs script where job outputs (output_types and has_patch) were not being set in early return paths and error handlers, causing downstream workflow jobs to skip incorrectly when they checked conditions like needs.agent.outputs.output_types != ''.

Changes:

  • Set all three job outputs (output, output_types, has_patch) in early return paths when no output file is configured or when the output file doesn't exist
  • Set all three job outputs in the error catch block before calling setFailed()
  • Added test assertions to verify that all outputs are properly set in early return scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/collect_ndjson_output.cjs Added core.setOutput() calls for output_types and has_patch in two early return paths (lines 170-171, 177-178) and in the error catch block (lines 342-344) to ensure all job outputs are consistently defined
actions/setup/js/collect_ndjson_output.test.cjs Enhanced existing tests for early return scenarios to verify that output_types and has_patch outputs are properly set, ensuring the fix is covered by tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan pelikhan merged commit e835351 into main Feb 14, 2026
152 checks passed
@pelikhan pelikhan deleted the copilot/fix-collect-ndjson-output branch February 14, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: collect_ndjson_output.cjs doesn't set job outputs, breaking workflow chain

3 participants