fix(ops): validate error_type against known whitelist before classification
Upstream proxies (account 4, 112) return `"<nil>"` as the error.type in
their JSON responses — a Go fmt.Sprintf("%v", nil) artifact. Since
`normalizeOpsErrorType` only checked for empty string, the literal
"<nil>" passed through and poisoned the entire classification chain:
error_phase was misclassified as "internal" (instead of "request"),
severity was inflated to P2, and the stored error_type was meaningless.
Add `isKnownOpsErrorType` whitelist so any unrecognised type falls
through to the code-based or default "api_error" classification.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -939,8 +939,29 @@ func guessPlatformFromPath(path string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// isKnownOpsErrorType returns true if t is a recognized error type used by the
|
||||
// ops classification pipeline. Upstream proxies sometimes return garbage values
|
||||
// (e.g. the Go-serialized literal "<nil>") which would pollute phase/severity
|
||||
// classification if accepted blindly.
|
||||
func isKnownOpsErrorType(t string) bool {
|
||||
switch t {
|
||||
case "invalid_request_error",
|
||||
"authentication_error",
|
||||
"rate_limit_error",
|
||||
"billing_error",
|
||||
"subscription_error",
|
||||
"upstream_error",
|
||||
"overloaded_error",
|
||||
"api_error",
|
||||
"not_found_error",
|
||||
"forbidden_error":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func normalizeOpsErrorType(errType string, code string) string {
|
||||
if errType != "" {
|
||||
if errType != "" && isKnownOpsErrorType(errType) {
|
||||
return errType
|
||||
}
|
||||
switch strings.TrimSpace(code) {
|
||||
|
||||
Reference in New Issue
Block a user