Block silent detection pass and classify Claude embedded 429 rate limits#31081
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix detection job handling for 429 rate-limit error and exit code 1
Block silent detection pass and classify Claude embedded 429 rate limits
May 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes threat-detection failure classification and “fail-open” behavior by (1) recognizing additional Claude CLI embedded 429/rate-limit signals and (2) ensuring the detection conclusion logic fails closed when the detection execution step itself failed, even if continue-on-error is enabled.
Changes:
- Wire
steps.detection_agentic_execution.outcomeinto the parse/conclude step env and use it to force failure on execution-failure + parse/agent failures. - Expand Claude harness rate-limit matching to catch stream-json embedded 429 indicators and common 429 message variants.
- Add targeted regression tests for the new env wiring and failure-escalation behavior.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/threat_detection.go | Passes execution outcome into parse/conclude env and updates generated github-script fallback to fail when execution failed. |
| pkg/workflow/detection_success_test.go | Verifies compiled workflow includes the new DETECTION_AGENTIC_EXECUTION_OUTCOME env var. |
| actions/setup/js/parse_threat_detection_results.cjs | Escalates parse/agent failures to hard failure when execution outcome indicates failure. |
| actions/setup/js/parse_threat_detection_results.test.cjs | Adds coverage for “execution failed => must fail even in warn mode”. |
| actions/setup/js/claude_harness.cjs | Broadens 429/rate-limit detection regex used by the Claude CLI harness. |
| actions/setup/js/claude_harness.test.cjs | Adds unit tests for newly recognized embedded-429 signals. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
actions/setup/js/parse_threat_detection_results.cjs:285
setDetectionFailure()uses warn-mode behavior for all reasons except the newmustFailcases. Because the downstream safe_outputs gate checksneeds.detection.result == 'success'(not thesuccessoutput), callingsetDetectionFailure('threat_detected', ...)in warn mode will not fail the step/job and can allow safe outputs to proceed even when threats are detected. Treatreason === 'threat_detected'as always-fatal (or otherwise ensure the detection job result isfailurewhen threats are present), independent of continue-on-error.
function setDetectionFailure(reason, message) {
const mustFail = detectionExecutionFailed && (reason === "agent_failure" || reason === "parse_error");
core.setOutput("reason", reason);
if (isWarnMode && !mustFail) {
core.warning(`⚠️ ${message}`);
core.setOutput("conclusion", "warning");
core.setOutput("success", "false");
} else {
core.setOutput("conclusion", "failure");
- Files reviewed: 6/6 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The detection flow had two coupled failure-mode bugs: Claude CLI embedded 429s were not recognized as rate-limit errors, and detection could still conclude
warning/green after a hard CLI failure with noTHREAT_DETECTION_RESULT. This change makes 429 classification resilient to stream-json payloads and makes detection fail closed when execution itself failed.Bug Fix
What was the bug?
api_error_status: 429/Request rejected (429)), so retry classification was wrong.warningfor parse/agent failures even when the detection execution step had already failed, allowing downstreamsafe_outputsprogression.How did you fix it?
isRateLimitErrormatching to include embedded stream-json 429 indicators and common 429 message variants.steps.detection_agentic_execution.outcomeinto parse/conclude env asDETECTION_AGENTIC_EXECUTION_OUTCOME.parse_threat_detection_results.cjs, escalateagent_failure/parse_errorto hard failure when execution outcome isfailure, even if continue-on-error is enabled.github-scriptload-error fallback logic.