Skip to content

Honor GH_AW_DETECTION_CONTINUE_ON_ERROR in detection setup to prevent false job failures - #49415

Merged
pelikhan merged 4 commits into
mainfrom
copilot/aw-failures-fix-job-conclusion
Aug 1, 2026
Merged

Honor GH_AW_DETECTION_CONTINUE_ON_ERROR in detection setup to prevent false job failures#49415
pelikhan merged 4 commits into
mainfrom
copilot/aw-failures-fix-job-conclusion

Conversation

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Detection jobs could still conclude as failure when GH_AW_DETECTION_CONTINUE_ON_ERROR=true if setup failed before detection_result.json existed (notably when agent_output.json was missing). This change aligns setup-phase failure behavior with conclude-phase continue-on-error semantics so missing detection inputs degrade to warnings in warn mode.

  • Behavioral alignment: setup phase now respects continue-on-error

    • setup_threat_detection.cjs now reads GH_AW_DETECTION_CONTINUE_ON_ERROR (case-insensitive, default true) and propagates it into required input checks.
  • Failure-path correction in shared file existence helper

    • checkFileExists(...) in file_helpers.cjs now accepts an optional continueOnError flag.
    • For required missing files:
      • continueOnError=true → emit warning, do not call core.setFailed.
      • continueOnError=false → preserve existing hard-fail behavior.
  • Targeted regression coverage

    • Added tests for:
      • missing required file + continue mode => warning/no setFailed
      • missing agent_output.json in setup + continue mode enabled/disabled behavior split.
// setup_threat_detection.cjs
const continueOnError = (process.env.GH_AW_DETECTION_CONTINUE_ON_ERROR || "true").toLowerCase() !== "false";

if (!checkFileExists(agentOutputPath, threatDetectionDir, "Agent output file", true, continueOnError)) {
  return;
}

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

run: https://github.com/github/gh-aw/actions/runs/30676859249

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.7 AIC · ⊞ 5.7K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix job conclusion logic for detection job Honor GH_AW_DETECTION_CONTINUE_ON_ERROR in detection setup to prevent false job failures Jul 31, 2026
Copilot AI requested a review from pelikhan July 31, 2026 21:56
@pelikhan
pelikhan marked this pull request as ready for review August 1, 2026 00:39
Copilot AI review requested due to automatic review settings August 1, 2026 00:39

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

Updates threat-detection setup so missing inputs can warn instead of failing.

Changes:

  • Adds continue-on-error handling to required-file checks.
  • Reads the detection policy during setup.
  • Adds regression tests for warning and strict modes.
Show a summary per file
File Description
actions/setup/js/setup_threat_detection.test.cjs Tests missing agent-output behavior.
actions/setup/js/setup_threat_detection.cjs Applies continue-on-error during setup.
actions/setup/js/file_helpers.test.cjs Tests warning-mode file checks.
actions/setup/js/file_helpers.cjs Adds optional warning behavior for missing files.

Review details

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Balanced

* @returns {Promise<void>}
*/
async function main() {
const continueOnError = (process.env.GH_AW_DETECTION_CONTINUE_ON_ERROR || "true").toLowerCase() !== "false";
Comment on lines +77 to +80
if (continueOnError) {
core.warning(`${ERR_SYSTEM}: ❌ ${fileDescription} not found at: ${filePath}. Continuing because GH_AW_DETECTION_CONTINUE_ON_ERROR=true`);
} else {
core.setFailed(`${ERR_SYSTEM}: ❌ ${fileDescription} not found at: ${filePath}`);
// The artifact contains /tmp/gh-aw/agent_output.json which becomes /tmp/gh-aw/threat-detection/agent_output.json
const agentOutputPath = path.join(threatDetectionDir, AGENT_OUTPUT_FILENAME);
if (!checkFileExists(agentOutputPath, threatDetectionDir, "Agent output file", true)) {
if (!checkFileExists(agentOutputPath, threatDetectionDir, "Agent output file", true, continueOnError)) {
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #49415 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions github-actions Bot mentioned this pull request Aug 1, 2026

@github-actions github-actions Bot 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.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — requesting changes. The fix direction is correct, but three issues need resolution before the behavior is clean.

📋 Key Themes

Issues to address

  1. core.error fires unconditionally before the continueOnError branch (file_helpers.cjs line 67) — warn mode still produces an error annotation, which is the same observable failure signal the PR is trying to suppress. See existing comment on line 80 of file_helpers.cjs.

  2. GH_AW_DETECTION_CONTINUE_ON_ERROR is not injected into the generated workflow step (setup_threat_detection.cjs line 28) — the env var will be absent at runtime unless explicitly forwarded. See existing comment.

  3. Only the agent_output.json check is patched (setup_threat_detection.cjs) — the download-check at lines 98–101 still calls core.setFailed unconditionally, so jobs can still false-fail on the other required input. See existing comment on line 77.

  4. New test asserts the broken core.error side-effect (file_helpers.test.cjs line 130) — this makes the test a false-green that validates the bug, not the fix.

Positive highlights

  • ✅ Correct default semantics: env var defaults to "true", matching the conclude-phase behavior.
  • ✅ Case-insensitive parsing of the env var.
  • ✅ Both enabled and disabled paths covered in setup_threat_detection.test.cjs.
  • ✅ Clean early-return on warn-mode missing file.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 28.7 AIC · ⊞ 7K
Comment /matt to run again

const result = checkFileExists(filePath, tempDir, "Test file", true, true);
expect(result).toBe(false);
expect(mockCore.errorCalls.some(msg => msg.includes("Test file not found"))).toBe(true);
expect(mockCore.warningCalls.some(msg => msg.includes("Continuing because GH_AW_DETECTION_CONTINUE_ON_ERROR=true"))).toBe(true);

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.

[/diagnosing-bugs] This assertion encodes the broken behavior — it expects core.error to fire even in continueOnError=true mode, making it a false-green test that passes only while the bug exists.

💡 What to fix

Line 67 of file_helpers.cjs calls core.error(...) unconditionally before the continueOnError branch. Once that call is guarded (see companion comment), this assertion must be inverted:

// After fixing file_helpers.cjs:
expect(mockCore.errorCalls).toHaveLength(0); // no error annotation in warn mode
expect(mockCore.warningCalls.some(msg => msg.includes("Test file not found"))).toBe(true);

Leaving the errorCalls assertion as-is means the test will start failing after the correct fix is applied, or worse, give false confidence that warn mode is clean when it is not.

@copilot please address this.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🧪 Test Quality Sentinel Report

Test Quality Score: 90/100 — Excellent

Analyzed 5 test(s): 5 design, 0 implementation, 0 violation(s).

📊 Metrics (5 tests)
Metric Value
Analyzed 5 (Go: 0, JS: 5)
✅ Design 5 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 5 (100%)
Duplicate clusters 0
Inflation YES (setup_threat_detection.test.cjs: 6:1)
🚨 Violations 0
Test File Classification Issues
continues with fallback workflow context when prompt artifact is missing setup_threat_detection.test.cjs design_test / high_value
warns but continues when prompt artifact is empty setup_threat_detection.test.cjs design_test / high_value
does not fail when agent output is missing and continue-on-error is enabled setup_threat_detection.test.cjs design_test / high_value
fails when agent output is missing and continue-on-error is disabled setup_threat_detection.test.cjs design_test / high_value
should return false and warn instead of failing when continueOnError is true file_helpers.test.cjs design_test / high_value
⚠️ Flagged Tests (1 — inflation only)

setup_threat_detection.test.cjs — test-to-prod ratio is 6:1 (+24 test lines vs +4 prod lines). This exceeds the 2:1 threshold. However, the tests cover multiple distinct behavioral paths of the GH_AW_DETECTION_CONTINUE_ON_ERROR feature being introduced, so the ratio is justified by the contract surface rather than padding. Not a hard violation.

Verdict

passed. 0% implementation tests (threshold: 30%). All 5 tests are design tests verifying behavioral contracts of the new continue-on-error path. No violations detected.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 37.2 AIC · ⊞ 8.4K ·
Comment /review to run again

@github-actions github-actions Bot 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.

✅ Test Quality Sentinel: 90/100. 0% implementation tests (threshold: 30%).

@github-actions github-actions Bot 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.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Review: Honor GH_AW_DETECTION_CONTINUE_ON_ERROR in detection setup

The intent is correct, but three blocking issues prevent the change from fully achieving its goal. All three are captured in inline comments — this summary consolidates them.

Blocking issues:

  1. core.error(...) fires unconditionally in warn mode (file_helpers.cjs ~line 67): in continueOnError=true path the step still emits an error annotation before the core.warning branch. This can cause conclusion: failure even without setFailed. The core.error call should be guarded the same way as core.setFailed.

  2. Patch/bundle check ignores continueOnError (setup_threat_detection.cjs ~lines 98–101): core.setFailed is called unconditionally when HAS_PATCH=true but no patch files are found — an identical gap to the one this PR aims to fix.

  3. GH_AW_DETECTION_CONTINUE_ON_ERROR is never injected into the generated step: the env var is read in main() but buildThreatDetectionAnalysisStep does not emit it. If the caller does not expose it, the default "true" in || "true" silently masks misconfiguration.

Non-blocking observations:

  • New tests are well-structured and cover agent-output happy/sad paths.
  • The parametric continueOnError addition to checkFileExists is the right abstraction.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 22.7 AIC · ⊞ 5.3K

@github-actions github-actions Bot 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.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Verdict: Request Changes

The core fix does not actually work in production: GH_AW_DETECTION_CONTINUE_ON_ERROR is never wired into the "Setup threat detection" step's env block, so the new continue-on-error branch always falls back to its hardcoded default and cannot be configured. Two additional consistency issues (unconditional patch/bundle failure, error+warning double-annotation) undermine the stated goal of aligning setup-phase and conclude-phase failure semantics.

💡 Themes
  • Critical wiring gap: buildThreatDetectionAnalysisStep in pkg/workflow/threat_detection_steps.go never emits GH_AW_DETECTION_CONTINUE_ON_ERROR into the "Setup threat detection" step's env, unlike buildDetectionConclusionStep which does this correctly for the later step. Verified against generated .lock.yml files (e.g. ab-testing-advisor.lock.yml) — the env block only has WORKFLOW_NAME, WORKFLOW_DESCRIPTION, HAS_PATCH. This means the new unit tests pass (they set process.env directly) but the real GitHub Actions env never populates the variable, so the fix is inert for actual workflow runs and users can't opt into strict (fail-fast) mode as intended.
  • Inconsistent policy application: the patch/bundle existence check in setup_threat_detection.cjs still calls core.setFailed unconditionally, while the agent-output check was updated to respect continueOnError. Same function, same "required downloaded input" category, different failure behavior.
  • Misleading log output: checkFileExists still emits an unconditional core.error(...) before choosing warn vs. fail, so warn mode produces both an error annotation and a warning annotation for the same event.

Tests added are reasonable for the JS-level API but don't cover the Go step-generation layer, which is where the actual defect lives — that's why the missing env wiring wasn't caught.

🔎 Code quality review by PR Code Quality Reviewer · auto · 62.1 AIC · ⊞ 7.8K
Comment /review to run again

Comments that could not be inline-anchored

actions/setup/js/setup_threat_detection.cjs:98

This patch/bundle existence check still calls core.setFailed unconditionally, ignoring the new continueOnError policy applied a few lines above to the agent-output check.

<details>
<summary>💡 Details</summary>

Line 77 now gates the missing agent_output.json failure on , but this block at line 98-101:

still hard-fails regardless of . If the stated goal is that missing required setup inputs should degrade to warnings in warn mode, this check is inconsistent: a missing agent output file is…

actions/setup/js/file_helpers.cjs:67

In warn mode this still emits an unconditional core.error(...) annotation before the new warning, so "continue on error" still surfaces as a CI error annotation, not just a warning.

<details>
<summary>💡 Details</summary>

Line 67 (core.error(&quot;❌ &quot; + fileDescription + &quot; not found at: &quot; + filePath);) runs unconditionally before the continueOnError branch that decides between core.warning and core.setFailed. So in warn mode the log/UI ends up with both an "error" annotation (from line 6…

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: bug (job conclusion / continue-on-error handling)
  • Risk: medium
  • Priority score: 60/100 (impact 30, urgency 20, quality 10)
  • Mergeable state: blocked (changes requested twice)
  • Recommended action: fast_track - bug affecting CI reliability; resolve open review feedback first

Generated by 🔧 PR Triage Agent · auto · 44.8 AIC · ⌖ 5.88 AIC · ⊞ 7.9K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot Please address the outstanding review feedback, refresh the branch, and run the pr-finisher skill before handing back for maintainer review.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.7 AIC · ⊞ 5.7K ·
Comment /souschef to run again

…ontinueOnError in patch check, emit env var in setup step

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Great work! 🚀 This PR addresses a critical bug where detection jobs were failing despite GH_AW_DETECTION_CONTINUE_ON_ERROR=true (issue #49351).

What's solid here:

  • Focused fix — changes are isolated to threat detection setup phase
  • Full test coverage — both "continue" and "hard-fail" scenarios are tested
  • Backward compatible — existing boolean behavior is preserved; new continueOnError flag defaults to false
  • Clear semantics — helper function now emits warnings instead of failures when appropriate

The PR looks ready for review and merge. The implementation aligns setup-phase error handling with conclude-phase semantics, fixing the false job failures described in the issue.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • patchdiff.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "patchdiff.githubusercontent.com"

See Network Configuration for more information.

Generated by ✅ Contribution Check · auto · 60 AIC · ⊞ 8.7K ·

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

[!WARNING]
threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding....

All three review issues addressed in this commit:

  1. file_helpers.cjscore.error(...) is now gated on !continueOnError. In warn mode, only a core.warning is emitted (no error annotation). The test for this case no longer expects any errorCalls.

  2. setup_threat_detection.cjs — The patch/bundle existence check at lines 98–101 now honors continueOnError: warns and continues when enabled, fails hard when disabled. Two new tests cover both modes.

  3. threat_detection_steps.gobuildThreatDetectionAnalysisStep now extracts continueOnError/continueOnErrorExpr with the same logic as buildDetectionConclusionStep and emits GH_AW_DETECTION_CONTINUE_ON_ERROR into the setup step's env. Two new Go test cases verify both default-true and explicit-false configurations.

Copilot AI requested a review from gh-aw-bot August 1, 2026 01:28
@pelikhan
pelikhan merged commit ce344f3 into main Aug 1, 2026
37 checks passed
@pelikhan
pelikhan deleted the copilot/aw-failures-fix-job-conclusion branch August 1, 2026 01:43
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw-failures] Detection job reports failure conclusion despite GH_AW_DETECTION_CONTINUE_ON_ERROR=true

4 participants