fix: use gofalcon SDK's actual error interfaces for status extraction#63
fix: use gofalcon SDK's actual error interfaces for status extraction#63c1-dev-bot[bot] wants to merge 1 commit into
Conversation
…ction
The extractCrowdStrikeError function defined a csError interface
(GetErrors() []models.MsaAPIError) that no gofalcon SDK type
implements. This caused ALL error extraction to fail silently,
falling through to string-matching which missed HTTP 502, 504,
and other status codes — producing codes.Unknown (gRPC) which
maps to HTTP 500 with no useful classification.
Fix by:
- Using the httpCoder interface (Code() int) that typed gofalcon
response errors actually implement
- Detecting runtime.APIError for unhandled status codes
- Adding 502, 504, "bad gateway", "gateway timeout" to fallback
- Adding OAuth2 error patterns ("access_denied", "invalid client")
Fixes: CXH-2022
| // Authentication errors | ||
| if strings.Contains(errMsg, "401") || strings.Contains(errMsg, "unauthorized") { | ||
| if strings.Contains(errMsg, "401") || strings.Contains(errMsg, "unauthorized") || | ||
| strings.Contains(errMsg, "access_denied") || strings.Contains(errMsg, "invalid client") { |
There was a problem hiding this comment.
🟡 Suggestion: The OAuth2 error code is invalid_client (underscore), but this matches "invalid client" (space), so it likely won't match the actual token-endpoint error string (e.g. golang.org/x/oauth2 renders oauth2: "invalid_client" ...). Consider strings.Contains(errMsg, "invalid_client"). (Confidence: medium — most such failures also contain "401"/"unauthorized" and would still be caught.)
| // | ||
| // 2. Generic runtime.APIError for status codes not covered by the swagger | ||
| // spec — these carry the code in the APIError.Code field. | ||
| func extractCrowdStrikeError(err error) (int, string) { |
There was a problem hiding this comment.
🟡 Suggestion: This changes error classification substantially — the old csError/GetErrors() path was dead code, so nearly all errors previously fell through to codes.Unknown. There are no tests for extractCrowdStrikeError. A table-driven errors_test.go covering a typed gofalcon error (e.g. QueryUserV1Forbidden), a *runtime.APIError, and the string fallback would guard this behavior against regressions. (Confidence: medium)
Connector PR Review: fix: use gofalcon SDK's actual error interfaces for status extractionBlocking Issues: 0 | Suggestions: 3 | Threads Resolved: 0 Review Summary Security Issues Correctness Issues Suggestions
Prompt for AI agents |
Summary
Fixes broken error extraction in the CrowdStrike connector that caused all API errors to be classified as
codes.Unknown(gRPC), which surfaces as HTTP 500 with no useful error classification.Root Cause
extractCrowdStrikeErrordefined acsErrorinterface requiringGetErrors() []models.MsaAPIError, but no gofalcon SDK type implements this interface. The SDK's typed error responses (e.g.QueryUserV1InternalServerError) useCode() intandGetPayload()instead. This meant the structured error extraction always returned(0, ""), forcing every error through the string-matching fallback.The fallback itself had gaps — it checked for "500" and "503" but not "502" (Bad Gateway) or "504" (Gateway Timeout), and missed common OAuth2 error patterns. Errors from infrastructure (CDN/load balancer 502s) or OAuth2 token failures fell through to the default
codes.Unknowncase.Changes
csErrorinterface withhttpCoder(Code() int) that typed gofalcon SDK errors actually implementruntime.APIErrordetection for status codes not covered by the swagger spec (the gofalcon SDK's default handler for unexpected HTTP responses)Impact
Errors from the CrowdStrike Falcon API will now be properly classified (e.g. 502 →
codes.Unavailableinstead ofcodes.Unknown), enabling correct retry behavior and meaningful error messages for users.Fixes: CXH-2022
Automated PR Notice
This PR was automatically created by c1-dev-bot as a potential implementation.
This code requires: