{"record":{"id":"34b31a0413792fd0","repo":"JuliusBrussee/caveman","slug":"unknown-trace-filter-s-unknown-sort-join","errorCode":null,"errorMessage":"unknown trace filter(s): ${unknown.sort().join(\", \")}","messagePattern":"unknown trace filter\\(s\\): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/agent-mcp.ts","lineNumber":450,"sourceCode":"    content: [{ type: \"text\", text: JSON.stringify(structuredContent) }],\n    structuredContent,\n    isError: true,\n  };\n}\n\nasync function withProjectQuery(client: AgentMcpClient, path: string): Promise<string> {\n  if (!PROJECT_QUERY_PATHS.has(path)) return path;\n  const projectId = await client.projectId();\n  const query = new URLSearchParams({ project_id: projectId });\n  return `${path}?${query}`;\n}\n\nfunction validateTraceFilters(args: JSONObject): void {\n  const filters = args.filters;\n  if (filters === undefined) return;\n  if (!filters || typeof filters !== \"object\" || Array.isArray(filters)) throw new Error(\"filters must be an object\");\n  const unknown = Object.keys(filters).filter((key) => !TRACE_FILTER_KEYS.has(key));\n  if (unknown.length > 0) throw new Error(`unknown trace filter(s): ${unknown.sort().join(\", \")}`);\n  const stringListKeys = [\n    \"workflow\",\n    \"agent\",\n    \"model\",\n    \"provider\",\n    \"error_code\",\n    \"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) {","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/cli/src/agent-mcp.ts#L432-L468","documentation":"validateTraceFilters() allowlists filter keys against TRACE_FILTER_KEYS. Any key outside that set (workflow, agent, model, provider, error_code, auth_mode, runtime_mode, cache_status, session_id, client_user_hash, trace_id, member_user_id, api_key_id, optimization_id, status_class, the numeric/boolean ranges, and monitor) is rejected by name, sorted, in the error message.","triggerScenarios":"Sending {\"filters\": {\"model_name\": [...]}} or {\"status\": \"error\"} — keys that are not in the recognized set; using dashboard/API filter names that differ from the MCP tool's vocabulary.","commonSituations":"Porting filter names from the REST API or UI that don't match this tool's schema; typos (\"erro_code\"); stale names after a CLI version renamed filters.","solutions":["Read the rejected key names in the message and map each to the closest allowlisted key (e.g. status -> status_class or error_code).","Check TRACE_FILTER_KEYS/this CLI version's tool schema for the exact accepted names.","Upgrade the caveman CLI if a filter you expect is missing — new filters arrive with CLI releases."],"exampleFix":"// before\n{ filters: { status: [\"error\"], model_name: [\"gpt-4\"] } }\n\n// after\n{ filters: { error_code: [\"provider_error\"], model: [\"gpt-4\"] } }","handlingStrategy":"validation","validationCode":"const TRACE_FILTER_KEYS = new Set([\"workflow\",\"agent\",\"model\",\"provider\",\"error_code\",\"auth_mode\",\"runtime_mode\",\"cache_status\",\"session_id\",\"client_user_hash\",\"trace_id\",\"member_user_id\",\"api_key_id\",\"optimization_id\",\"status_class\",\"min_cost_usd\",\"max_cost_usd\",\"min_total_tokens\",\"max_total_tokens\",\"min_latency_ms\",\"max_latency_ms\",\"has_error\",\"compressed\",\"monitor\"]);\nconst bad = Object.keys(filters).filter((k) => !TRACE_FILTER_KEYS.has(k));\nif (bad.length) throw new Error(`unknown filter keys: ${bad.join(\", \")}`);","typeGuard":"function isKnownFilterKey(k: string): boolean { return TRACE_FILTER_KEYS.has(k); }","tryCatchPattern":null,"preventionTips":["Keep a local copy of the allowlist in sync with your CLI version.","Parse the sorted key list out of the error to fix calls programmatically."],"tags":["mcp","validation","filters","traces"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}