JuliusBrussee/caveman · error

filter monitor.id is required

Error message

filter monitor.id is required

What it means

When a `monitor` filter object is present in trace_search arguments, validateTraceFilters requires `monitor.id` to be a non-empty string. Omitting it, passing null, or passing an empty/whitespace-only string throws this error.

Solutions

  1. Provide a non-empty string `monitor.id`, e.g. {"id":"m_123","verdict":"pass"}.
  2. If you only want to filter by verdict without a specific monitor, use a different filter or tool (monitor filtering here is per-monitor).
  3. Trim/validate the id string before calling (empty or whitespace-only fails).
  4. Confirm the id value is a string, not a number or object.

Example fix

// before
{ "filter": { "monitor": { "verdict": "fail" } } }
// after
{ "filter": { "monitor": { "id": "mon_01H...", "verdict": "fail" } } }
Defensive patterns

Strategy: validation

Validate before calling

if (filter.monitor && (typeof filter.monitor.id !== "string" || filter.monitor.id.trim() === ""))
  throw new Error("monitor.id must be a non-empty string before calling trace_search");

Type guard

function hasMonitorId(m) {
  return typeof m?.id === "string" && m.id.trim().length > 0;
}

Try / catch

try {
  await traceSearch(args);
} catch (e) {
  if (e.message === "filter monitor.id is required") {
    throw new Error("Supply the monitor id you want verdict-filtered results for");
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling trace_search with {"filter":{"monitor":{"verdict":"pass"}}}, {"filter":{"monitor":{"id":"","verdict":"pass"}}}, or {"filter":{"monitor":{"id":123}}} — monitor present but id missing, empty, or not a string.

Common situations: Building the filter programmatically and leaving id undefined when only verdict is known; template/serializing bugs that drop empty strings; passing a numeric monitor id from another system.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/8f376c2db4fdfaab. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/agent-mcp.ts:493

      throw new Error("filter status_class values must be 2xx, 4xx, or 5xx");
    }
  }
  for (const key of ["min_cost_usd", "max_cost_usd", "min_total_tokens", "max_total_tokens", "min_latency_ms", "max_latency_ms"]) {
    const value = filters[key];
    if (value !== undefined && (typeof value !== "number" || !Number.isFinite(value))) {
      throw new Error(`filter ${key} must be a finite number`);
    }
  }
  for (const key of ["has_error", "compressed"]) {
    const value = filters[key];
    if (value !== undefined && typeof value !== "boolean") throw new Error(`filter ${key} must be a boolean`);
  }
  const monitor = filters.monitor;
  if (monitor !== undefined) {
    if (!monitor || typeof monitor !== "object" || Array.isArray(monitor)) throw new Error("filter monitor must be an object");
    const monitorUnknown = Object.keys(monitor).filter((key) => key !== "id" && key !== "verdict");
    if (monitorUnknown.length > 0) throw new Error(`filter monitor has unknown key(s): ${monitorUnknown.sort().join(", ")}`);
    if (typeof monitor.id !== "string" || monitor.id.trim() === "") throw new Error("filter monitor.id is required");
    if (typeof monitor.verdict !== "string" || !["pass", "fail", "error"].includes(monitor.verdict)) {
      throw new Error("filter monitor.verdict must be pass, fail, or error");
    }
  }
}

function optionalEnum(args: JSONObject, key: string, values: string[]): void {
  const value = args[key];
  if (value !== undefined && (typeof value !== "string" || !values.includes(value))) {
    throw new Error(`${key} must be one of ${values.join(", ")}`);
  }
}

function validateTraceSearch(args: JSONObject): void {
  validateTraceFilters(args);
  for (const key of ["from", "to"]) {
    const value = args[key];
    if (value !== undefined && typeof value !== "string") throw new Error(`${key} must be a string`);

View on GitHub (pinned to 3ee70a1026)