{"record":{"id":"baeddedb7622d3f2","repo":"JuliusBrussee/caveman","slug":"filter-status-class-values-must-be-2xx-4xx-or-5x","errorCode":null,"errorMessage":"filter status_class values must be 2xx, 4xx, or 5xx","messagePattern":"filter status_class values must be 2xx, 4xx, or 5xx","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/agent-mcp.ts","lineNumber":475,"sourceCode":"    \"auth_mode\",\n    \"runtime_mode\",\n    \"cache_status\",\n    \"session_id\",\n    \"client_user_hash\",\n    \"trace_id\",\n    \"member_user_id\",\n    \"api_key_id\",\n    \"optimization_id\",\n    \"status_class\",\n  ];\n  for (const key of stringListKeys) {\n    const value = filters[key];\n    if (value === undefined) continue;\n    if (!Array.isArray(value) || value.length === 0 || value.some((entry) => typeof entry !== \"string\" || entry.trim() === \"\")) {\n      throw new Error(`filter ${key} must be a non-empty array of non-empty strings`);\n    }\n    if (key === \"status_class\" && value.some((entry) => ![\"2xx\", \"4xx\", \"5xx\"].includes(entry as string))) {\n      throw new Error(\"filter status_class values must be 2xx, 4xx, or 5xx\");\n    }\n  }\n  for (const key of [\"min_cost_usd\", \"max_cost_usd\", \"min_total_tokens\", \"max_total_tokens\", \"min_latency_ms\", \"max_latency_ms\"]) {\n    const value = filters[key];\n    if (value !== undefined && (typeof value !== \"number\" || !Number.isFinite(value))) {\n      throw new Error(`filter ${key} must be a finite number`);\n    }\n  }\n  for (const key of [\"has_error\", \"compressed\"]) {\n    const value = filters[key];\n    if (value !== undefined && typeof value !== \"boolean\") throw new Error(`filter ${key} must be a boolean`);\n  }\n  const monitor = filters.monitor;\n  if (monitor !== undefined) {\n    if (!monitor || typeof monitor !== \"object\" || Array.isArray(monitor)) throw new Error(\"filter monitor must be an object\");\n    const monitorUnknown = Object.keys(monitor).filter((key) => key !== \"id\" && key !== \"verdict\");\n    if (monitorUnknown.length > 0) throw new Error(`filter monitor has unknown key(s): ${monitorUnknown.sort().join(\", \")}`);\n    if (typeof monitor.id !== \"string\" || monitor.id.trim() === \"\") throw new Error(\"filter monitor.id is required\");","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/cli/src/agent-mcp.ts#L457-L493","documentation":"The status_class filter accepts only the coarse HTTP classes \"2xx\", \"4xx\", \"5xx\" as array entries. Any other string (\"200\", \"3xx\", \"success\", \"error\") in the status_class array is rejected.","triggerScenarios":"filters.status_class = [\"200\", \"404\"]; using \"3xx\" for redirects; using semantic labels like \"success\"/\"server_error\" instead of the class form.","commonSituations":"Mapping from an internal taxonomy that tracks exact codes or words; a model guessing the format from context.","solutions":["Convert exact codes to their class: 2xx for 2NN, 4xx for 4NN, 5xx for 5NN.","Use only the literals \"2xx\", \"4xx\", \"5xx\".","For semantic filtering, combine status_class with has_error instead of inventing labels."],"exampleFix":"// before\n{ filters: { status_class: [\"200\", \"500\"] } }\n\n// after\n{ filters: { status_class: [\"2xx\", \"5xx\"] } }","handlingStrategy":"validation","validationCode":"function toStatusClass(code: number | string): \"2xx\" | \"4xx\" | \"5xx\" {\n  const c = typeof code === \"number\" ? code : parseInt(code, 10);\n  if (c >= 200 && c < 300) return \"2xx\";\n  if (c >= 400 && c < 500) return \"4xx\";\n  if (c >= 500 && c < 600) return \"5xx\";\n  throw new Error(`no status_class for ${code}`);\n}","typeGuard":"function isStatusClass(v: string): v is \"2xx\" | \"4xx\" | \"5xx\" {\n  return [\"2xx\", \"4xx\", \"5xx\"].includes(v);\n}","tryCatchPattern":null,"preventionTips":["Normalize exact HTTP codes to class form before filtering.","Pin the vocabulary to the three literals in client code."],"tags":["mcp","validation","filters","status-codes"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}