JuliusBrussee/caveman · error
unknown trace filter(s)
Error message
unknown trace filter(s): ${unknown.sort().join(", ")} What it means
After confirming filters is an object, validateTraceFilters checks every key against the TRACE_FILTER_KEYS allowlist. Any key outside the allowlist throws with a sorted, comma-separated list of the offending keys, so callers cannot silently pass unrecognized filters that would be ignored downstream.
Solutions
- Remove or rename the unknown keys listed in the message to ones in TRACE_FILTER_KEYS
- Check the supported filter keys (workflow, agent, model, provider, error_code, status_class, cost/token/latency bounds, has_error, compressed, monitor, etc.)
- Validate user-supplied filters against the allowlist before forwarding
- If a needed filter genuinely doesn't exist, use the supported keys or an alternate tool rather than guessing
Example fix
// before
searchTraces({ filters: { username: ['bob'] } });
// after
searchTraces({ filters: { agent: ['bob'] } }); Defensive patterns
Strategy: validation
Validate before calling
const TRACE_FILTER_KEYS = new Set(['workflow','agent','model','provider','error_code','status_class','min_cost_usd','max_cost_usd','min_total_tokens','max_total_tokens','min_latency_ms','max_latency_ms','has_error','compressed','monitor']);
function assertKnownFilterKeys(filters) {
const unknown = Object.keys(filters ?? {}).filter((k) => !TRACE_FILTER_KEYS.has(k));
if (unknown.length) throw new Error(`unknown trace filter(s): ${unknown.sort().join(', ')}`);
} Try / catch
try {
await searchTraces({ filters });
} catch (error) {
if (error.message.startsWith('unknown trace filter(s)')) {
const bad = error.message.split(': ')[1].split(', ');
// drop or rename bad keys and retry
}
} Prevention
- Keep a shared constant of allowed filter keys in client code and validate against it
- Never forward raw user filter dicts verbatim; map them through an allowlist
- Check the current tool docs when upgrading — filter keys can be renamed
- Fix typos by validating filter keys in an IDE against the exported constant
When it happens
Trigger: Calling trace search with filters containing a key not in TRACE_FILTER_KEYS, e.g. filters: { user: 'bob' } or a misspelled known key like workflow_name or errorcode.
Common situations: Typos in filter names; inventing filters based on docs for a different API; forwarding user-supplied filter dicts verbatim; drift after a filter key was renamed in a newer version.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- filter must be a boolean
- filter must be a finite number
- filter must be a non-empty array of non-empty strings
- filter monitor must be an object
- filter status_class values must be 2xx, 4xx, or 5xx
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/34b31a0413792fd0.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/agent-mcp.ts:450
content: [{ type: "text", text: JSON.stringify(structuredContent) }],
structuredContent,
isError: true,
};
}
async function withProjectQuery(client: AgentMcpClient, path: string): Promise<string> {
if (!PROJECT_QUERY_PATHS.has(path)) return path;
const projectId = await client.projectId();
const query = new URLSearchParams({ project_id: projectId });
return `${path}?${query}`;
}
function validateTraceFilters(args: JSONObject): void {
const filters = args.filters;
if (filters === undefined) return;
if (!filters || typeof filters !== "object" || Array.isArray(filters)) throw new Error("filters must be an object");
const unknown = Object.keys(filters).filter((key) => !TRACE_FILTER_KEYS.has(key));
if (unknown.length > 0) throw new Error(`unknown trace filter(s): ${unknown.sort().join(", ")}`);
const stringListKeys = [
"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",
];
for (const key of stringListKeys) {View on GitHub (pinned to 3ee70a1026)