Skip to content

Honor detection continue-on-error when external detector result file is missing#40790

Merged
pelikhan merged 6 commits into
mainfrom
copilot/aw-failures-honor-detection-continue-on-error
Jun 22, 2026
Merged

Honor detection continue-on-error when external detector result file is missing#40790
pelikhan merged 6 commits into
mainfrom
copilot/aw-failures-honor-detection-continue-on-error

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

A transient failure in the external detection agent can leave detection_result.json absent; previously, detection conclude handling could hard-fail the detection job even when GH_AW_DETECTION_CONTINUE_ON_ERROR=true. This change keeps missing-result handling mode-aware so detection failures no longer incorrectly dominate otherwise successful runs.

  • External detector conclude path: script-backed missing-result fallback

    • Refactors conclude handling into actions/setup/sh/conclude_threat_detection.sh, invoked from buildExternalDetectorConcludeStep.
    • The script checks:
      • RUN_DETECTION == true
      • result file existence
      • normalized GH_AW_DETECTION_CONTINUE_ON_ERROR
    • If file is missing and continue-on-error is enabled, it emits a warning and writes degraded outputs instead of exiting non-zero:
      • conclusion=warning
      • success=false
      • reason=agent_failure
      • exports GH_AW_DETECTION_CONCLUSION=warning and GH_AW_DETECTION_REASON=agent_failure
    • If continue-on-error is disabled, behavior remains hard-fail (exit 1).
  • Contract preservation

    • The step still uses id: detection_conclusion and preserves downstream output/env contracts.
    • Existing strict/fail behavior is unchanged for explicit non-continue-on-error mode.
  • Coverage update

    • threat_detection_isolation_test.go now asserts the external-detector YAML invokes conclude_threat_detection.sh and preserves required conclude env wiring.
    • Added threat_detection_conclude_script_test.go to validate:
      • missing-result continue-on-error fallback emits warning-mode outputs/env
      • script invokes threat-detect conclude when result file exists.
if [ "${RUN_DETECTION:-false}" = "true" ] && [ ! -f "${RESULT_FILE}" ]; then
  if [ "${continue_on_error}" = "true" ]; then
    echo "::warning::Detection result file not found ...; continuing..."
    echo "conclusion=warning" >> "${GITHUB_OUTPUT}"
    echo "success=false" >> "${GITHUB_OUTPUT}"
    echo "reason=agent_failure" >> "${GITHUB_OUTPUT}"
    exit 0
  fi
  echo "ERR_SYSTEM: ❌ Detection result file not found at: ${RESULT_FILE}"
  exit 1
fi

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

\n\n---\n✨ PR Review Safe Output Test - Run 27980364818

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude · 114.8 AIC · ⊞ 8.5K ·

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix threat-detect conclude to honor GH_AW_DETECTION_CONTINUE_ON_ERROR Honor detection continue-on-error when external detector result file is missing Jun 22, 2026
Copilot AI requested a review from pelikhan June 22, 2026 15:09
@pelikhan pelikhan marked this pull request as ready for review June 22, 2026 17:05
Copilot AI review requested due to automatic review settings June 22, 2026 17:05

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 the external threat-detect conclude step generation so missing detection_result.json can be handled without incorrectly failing the detection job when continue-on-error mode is enabled, and extends the isolation test to assert the new emitted YAML content.

Changes:

  • Add a missing-result preflight in buildExternalDetectorConcludeStep that emits fallback step outputs/env and exits successfully in continue-on-error mode.
  • Keep strict-mode behavior as a hard failure when the result file is missing.
  • Update TestExternalDetectorPath to assert the generated YAML contains the missing-result fallback markers.
Show a summary per file
File Description
pkg/workflow/threat_detection.go Adds shell-level missing-result handling and emits fallback outputs/env before running threat-detect conclude.
pkg/workflow/threat_detection_isolation_test.go Adds assertions that the external-detector YAML includes the new fallback content.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 3

Comment thread pkg/workflow/threat_detection.go Outdated
Comment on lines +1288 to +1292
" echo \"conclusion=unknown\" >> \"$GITHUB_OUTPUT\"\n",
" echo \"success=false\" >> \"$GITHUB_OUTPUT\"\n",
" echo \"reason=agent_failure\" >> \"$GITHUB_OUTPUT\"\n",
" echo \"GH_AW_DETECTION_CONCLUSION=unknown\" >> \"$GITHUB_ENV\"\n",
" echo \"GH_AW_DETECTION_REASON=agent_failure\" >> \"$GITHUB_ENV\"\n",
Comment on lines +141 to +143
if !strings.Contains(detectionSection, "conclusion=unknown") {
t.Error("External detector path must degrade to conclusion=unknown when result file is missing in continue-on-error mode")
}
Comment on lines +144 to +146
if !strings.Contains(detectionSection, "GH_AW_DETECTION_CONCLUSION=unknown") {
t.Error("External detector path must export GH_AW_DETECTION_CONCLUSION=unknown for missing result fallback")
}
Comment thread pkg/workflow/threat_detection.go Outdated
coeEnvLine,
" run: |\n",
fmt.Sprintf(" threat-detect conclude --result-file %s\n", shellEscapeArg(constants.ThreatDetectionResultPath)),
fmt.Sprintf(" result_file=%s\n", shellEscapeArg(constants.ThreatDetectionResultPath)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot refactor to a script file in actions/setup/sh + add tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 5434a35. I refactored the external detection conclude logic into actions/setup/sh/conclude_threat_detection.sh, switched workflow generation to call that script, and added tests in pkg/workflow/threat_detection_conclude_script_test.go plus updated isolation assertions.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan June 22, 2026 17:29
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Ran a pr-finisher pass on this branch. Local validation is green (make fmt, make lint, make test-unit, make test, make recompile), no additional code changes were needed in this pass, and CI on the current PR head remains maintainer-owned for any re-trigger if needed before merge.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

Copy link
Copy Markdown
Contributor

📰 BREAKING: Smoke Copilot - AOAI (Entra) is now investigating this pull request. Sources say the story is developing...

@github-actions

Copy link
Copy Markdown
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.54.0
jq 1.7
yq v4.53.3
curl 8.5.0
gh 2.94.0
node v22.22.3
python3 3.11.15 (PyPy)
go 1.24.13
java 21.0.11
dotnet 10.0.301

Result: 12/12 tools available ✅

Overall Status: PASS

🔧 Tool validation by Agent Container Smoke Test · 18.5 AIC · ⌖ 12.2 AIC · ⊞ 5.4K ·

@github-actions

Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Smoke Test Results

  • GitHub MCP: ✅
  • Web Fetch: ✅
  • File Write: ✅
  • Bash Tool: ✅
  • Build gh-aw: ❌
    Overall Status: FAIL

Warning

Firewall blocked 1 domain

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

  • localhost

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

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

Smoke Gemini — Powered by Gemini ·

@github-actions

Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Smoke test FAIL

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex · 9.73 AIC · ⊞ 12.4K ·

@github-actions

Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Comment Memory

Build lights hum at dusk
GitHub mirrors in the glass
Checks drift into green

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex · 9.73 AIC · ⊞ 12.4K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results:
Review merged PRs: ✅
mcpscripts-gh PR query: ✅
Serena CLI symbols: ✅
Playwright navigation: ✅
Web fetch: ✅
File creation: ✅
Discussion comment: ✅
Build: ✅
Artifact upload: ✅
Discussion creation: ✅
Workflow dispatch: ✅
PR review: ✅
Comment memory: ✅
File summarizer: ✅
Check run: ✅

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot - AOAI (apikey) · 69 AIC · ⌖ 11.5 AIC · ⊞ 18.1K ·

@github-actions

Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

Honor detection continue-on-error when external detector result file is missing

❌ github tool
✅ mcpscripts
✅ Serena
✅ Playwright
❌ web-fetch
✅ file+bash
✅ discussion ping
✅ build
✅ artifact
✅ discussion create
✅ dispatch
✅ review tools
✅ comment memory
✅ sub-agent
✅ check run

FAIL
Author: app/copilot-swe-agent
Assignees: pelikhan, Copilot

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot · 429 AIC · ⌖ 13.7 AIC · ⊞ 19.2K ·

@github-actions

Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

Comment Memory

Stone test hums.
Bot tap rock bright.
Night CI sings.

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot · 429 AIC · ⌖ 13.7 AIC · ⊞ 19.2K ·

@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.

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

Smoke cave note: review tool path worked.

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot · 429 AIC · ⌖ 13.7 AIC · ⊞ 19.2K

@github-actions

Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Smoke Test: Claude — Run 27980364818

Core #1-12: all passed (MCP, GH CLI, Build, Playwright, Tavily, Files, Bash, Discussion, AW status, Slack, Code Scan, Check Run) ✅

PR Review #13-19: Update PR ✅ · Review Comments ✅ · Submit Review ✅ · Resolve Thread ✅ · Add Reviewer ✅ · Push Branch ✅ · Close PR ⚠️ skipped

Overall: PARTIAL (only #19 skipped — no safe test PR)

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude · 114.8 AIC · ⊞ 8.5K ·

@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.

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

💥 Automated smoke test review - all systems nominal!

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude · 114.8 AIC · ⊞ 8.5K

coeEnvLine,
" run: |\n",
fmt.Sprintf(" threat-detect conclude --result-file %s\n", shellEscapeArg(constants.ThreatDetectionResultPath)),
fmt.Sprintf(" bash \"${RUNNER_TEMP}/gh-aw/actions/conclude_threat_detection.sh\" %s\n", shellEscapeArg(constants.ThreatDetectionResultPath)),

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.

Nice — replacing the inline threat-detect conclude with a sourced shell script keeps the conclude logic testable. Worth a comment noting the script path contract.

@@ -1279,7 +1279,7 @@ func (c *Compiler) buildExternalDetectorConcludeStep(data *WorkflowData) []strin
" DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}\n",

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.

Consider asserting that the RUNNER_TEMP-based script exists before invoking, so a missing detector script fails clearly rather than via a bash not-found error.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot review failures in detection job. https://github.com/github/gh-aw/actions/runs/27980364818

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review failures in detection job. https://github.com/github/gh-aw/actions/runs/27980364818

Reviewed run 27980364818. The workflow and detection job both completed successfully, but the detection execution step logged an internal detector failure: failed to execute claude: exec: "claude": executable file not found in $PATH, which left detection_result.json missing. The new conclude script then correctly handled this under GH_AW_DETECTION_CONTINUE_ON_ERROR=true and downgraded to warning mode (GH_AW_DETECTION_CONCLUSION=warning, reason=agent_failure) instead of failing the job. So this run reflects expected behavior from the fix; the remaining warning is due to detector runtime availability in the AWF environment, not conclude handling.

@github-actions

Copy link
Copy Markdown
Contributor

Please summarize any remaining blockers around the continue-on-error handling.

Generated by 👨‍🍳 PR Sous Chef · 40.3 AIC · ⌖ 1.03 AIC · ⊞ 17.3K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot investigate why Claude was not found by the detection engine. Check differences with agent job.

https://github.com/github/gh-aw/actions/runs/27980364818/job/82810895179#step:18:1

@pelikhan pelikhan merged commit 537f546 into main Jun 22, 2026
209 of 210 checks passed
@pelikhan pelikhan deleted the copilot/aw-failures-honor-detection-continue-on-error branch June 22, 2026 21:56
Copilot stopped work on behalf of pelikhan due to an error June 22, 2026 21:56
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.

3 participants