Skip to content

fix: use [!WARNING] banner for threat detection engine failures instead of [!CAUTION] - #48940

Merged
pelikhan merged 4 commits into
mainfrom
copilot/deep-report-investigate-silent-failures
Jul 29, 2026
Merged

fix: use [!WARNING] banner for threat detection engine failures instead of [!CAUTION]#48940
pelikhan merged 4 commits into
mainfrom
copilot/deep-report-investigate-silent-failures

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

When the threat detection engine crashes (agent_failure) or produces unparseable output (parse_error), the resulting banner was visually identical to a genuine security finding — both showed [!CAUTION] agentic threat detected. Reviewers had no signal to distinguish a broken tooling job from an actual threat, causing alert fatigue and masking the real infrastructure bug.

Changes

  • threat_detection_warning.cjs — adds isToolingFailureReason(reason) returning true for agent_failure and parse_error

  • messages_run_status.cjsgetDetectionWarningMessage() now branches on isToolingFailureReason:

    • Tooling failures → [!WARNING] / threat detection engine error / detectionEngineError message key (user-customizable)
    • Actual findings → unchanged [!CAUTION] / agentic threat detected
  • generate_footer.cjsgetExpiredEntityCautionAlert() applies the same distinction (kept inline to avoid bundler/test issues with messages_footer.cjs)

Before / After

Reason Before After
threat_detected [!CAUTION] agentic threat detected [!CAUTION] agentic threat detected (unchanged)
agent_failure [!CAUTION] agentic threat detected [!WARNING] threat detection engine error
parse_error [!CAUTION] agentic threat detected [!WARNING] threat detection engine error

…findings

When the threat detection engine fails to produce results (reason:
agent_failure or parse_error), render a [!WARNING] banner titled
"threat detection engine error" instead of the [!CAUTION] "agentic
threat detected" banner used for real security findings.

This prevents alert fatigue and false urgency when the detection tool
itself crashes, making it clear to reviewers that the banner signals a
tooling failure rather than a genuine security threat.

Changes:
- threat_detection_warning.cjs: add isToolingFailureReason() helper
  that returns true for agent_failure and parse_error
- messages_run_status.cjs: getDetectionWarningMessage() uses
  [!WARNING]/detectionEngineError template for tooling failures and
  keeps [!CAUTION]/detectionWarning template for actual threats
- generate_footer.cjs: getExpiredEntityCautionAlert() applies the
  same distinction using the imported isToolingFailureReason()
- Tests updated and extended to cover all banner variants

Closes #48922

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate recurring threat-detection engine silent failures fix: use [!WARNING] banner for threat detection engine failures instead of [!CAUTION] Jul 29, 2026
Copilot AI requested a review from pelikhan July 29, 2026 16:23
@pelikhan
pelikhan marked this pull request as ready for review July 29, 2026 16:24
Copilot AI review requested due to automatic review settings July 29, 2026 16:24

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

Distinguishes threat-detection tooling failures from genuine security findings.

Changes:

  • Classifies agent_failure and parse_error as tooling failures.
  • Renders tooling failures with [!WARNING].
  • Adds coverage for classification and banner rendering.
Show a summary per file
File Description
actions/setup/js/threat_detection_warning.cjs Adds tooling-failure classification.
actions/setup/js/threat_detection_warning.test.cjs Tests reason classification.
actions/setup/js/messages_run_status.cjs Selects warning or caution messages.
actions/setup/js/messages.test.cjs Tests footer message behavior.
actions/setup/js/generate_footer.cjs Updates expired-entity alerts.
actions/setup/js/generate_footer.test.cjs Tests both tooling-failure reasons.

Review details

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Medium

const isEngineError = isToolingFailureReason(ctx.reason);
if (isEngineError) {
const defaultTemplate = `> [!WARNING]\n> threat detection engine error\n> The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.\n> ${getThreatDetectedMarkerTemplate()}\n>\n> <details>\n> <summary>Details</summary>\n>\n> {reason_text}\n>\n> Review the [workflow run logs]({run_url}) for details.\n> </details>`;
return renderConfiguredMessage("detectionEngineError", defaultTemplate, { ...ctx, reasonText, threatKinds: normalizeThreatKinds(ctx.reason) });
Comment on lines +67 to +69
function isToolingFailureReason(reason) {
const normalized = String(reason || "").trim();
return normalized === "agent_failure" || normalized === "parse_error";
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

No ADR enforcement needed: PR #48940 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 Jul 29, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 29, 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 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.

The changes look good. The separation of [!WARNING] for tooling failures (agent_failure, parse_error) vs [!CAUTION] for actual threat findings is a meaningful UX improvement. The isToolingFailureReason() helper is correctly implemented, well-documented, and has comprehensive test coverage.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 14.7 AIC · ⌖ 5.37 AIC · ⊞ 5.3K

@pelikhan
pelikhan merged commit 9ece29a into main Jul 29, 2026
8 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-investigate-silent-failures branch July 29, 2026 16:35
@github-actions github-actions Bot mentioned this pull request Jul 29, 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /codebase-design — requesting changes for two pre-existing comments plus one new finding.

📋 Key Themes & Highlights

Key Themes

  • Incomplete coverage (pre-existing comment #3676223067): push_to_pull_request_branch.cjs still hardcodes [!CAUTION] for the same warning conclusion, leaving a parallel code path un-fixed.
  • Unreachable config key (pre-existing comment #3676223001): detectionEngineError is not a supported key in SafeOutputMessagesConfig, so the user-customizable path is silently dead.
  • Duplicate template strings (new inline comment on generate_footer.cjs:135): identical warning template exists in two files with no shared constant; any wording change requires two edits.

Positive Highlights

  • ✅ Clean isToolingFailureReason predicate — well-named, single-responsibility, easy to extend.
  • ✅ Good test coverage with descriptive names that read as specifications.
  • ✅ Clear before/after table in the PR description makes the intent obvious.

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

}
const detectionReason = process.env.GH_AW_DETECTION_REASON || "";
const reasonText = getDetectionReasonText(detectionReason);
if (isToolingFailureReason(detectionReason)) {

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.

[/codebase-design] The inline template string here is a verbatim copy of the one in messages_run_status.cjs. Any future wording change to the warning banner must be applied in two places. Since threat_detection_warning.cjs is already imported by both files, extracting the shared template there would keep the wording in sync automatically.

💡 Suggested approach

In threat_detection_warning.cjs, export a constant:

const TOOLING_FAILURE_WARNING_TEMPLATE =
  `> [!WARNING]
> threat detection engine error
> The threat detection engine encountered an error...`;
module.exports = { ..., TOOLING_FAILURE_WARNING_TEMPLATE };

Both callers import and interpolate it, removing the duplication.

@copilot please address this.

@github-actions

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: 79/100 — Acceptable

Analyzed 9 test(s): 8 design, 1 implementation, 0 violation(s).

📊 Metrics (9 tests)
Metric Value
Analyzed 9 (Go: 0, JS: 9)
✅ Design 8 (89%)
⚠️ Implementation 1 (11%)
Edge/error coverage 7 (78%)
Duplicate clusters 0
Inflation YES (generate_footer.test.cjs +27 vs generate_footer.cjs +11 = 2.45:1)
🚨 Violations 0
Test File Classification Issues
should return warning alert for agent_failure generate_footer.test.cjs design_test / high_value None
should return warning alert for parse_error generate_footer.test.cjs design_test / high_value None
should return warning alert with agent_failure reason (modified) messages.test.cjs design_test / high_value None
should return caution alert with default reason when reason is empty (renamed) messages.test.cjs implementation_detail / low_value No assertion changes — rename only
isToolingFailureReason - returns true for agent_failure threat_detection_warning.test.cjs design_test / high_value None
isToolingFailureReason - returns true for parse_error threat_detection_warning.test.cjs design_test / high_value None
isToolingFailureReason - returns false for threat_detected threat_detection_warning.test.cjs design_test / high_value None
isToolingFailureReason - returns false for empty/null/undefined threat_detection_warning.test.cjs design_test / high_value Edge-case ✅
isToolingFailureReason - returns false for unknown reason threat_detection_warning.test.cjs design_test / high_value None
⚠️ Flagged Tests (1)

should return caution alert with default reason when reason is empty (messages.test.cjs) — implementation_detail, low_value. This is a test rename with no assertion changes; it confirms existing behavior but adds no new coverage. Consider adding .not.toContain("> [!WARNING]") to anchor the design contract explicitly.

Inflation note: generate_footer.test.cjs adds 27 lines against 11 production lines (2.45:1). The added tests are meaningful two-scenario blocks with multiple expect calls each — acceptable verbosity, not filler — but it triggers the inflation metric.

Verdict

passed. 11% implementation tests (threshold: 30%). No hard violations. Score capped slightly by test inflation metric.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 33.5 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: 79/100. 11% implementation tests (threshold: 30%). No violations.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.0

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.

[deep-report] Investigate recurring threat-detection engine silent failures ("failed to produce results")

3 participants