{"record":{"id":"59923e0f7ce2feb2","repo":"JuliusBrussee/caveman","slug":"tool-catalog-names-must-be-non-empty-and-unique","errorCode":null,"errorMessage":"tool catalog names must be non-empty and unique","messagePattern":"tool catalog names must be non-empty and unique","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":1620,"sourceCode":"    headers: headers(cave, workflow),\n    body: JSON.stringify(body)\n  });\n\tif (!response.ok) throw new Error(`tool search failed with HTTP ${response.status}`);\n  const data = await response.json();\n\n  // Map snake_case response to camelCase\n  const rawSent = strictNonNegativeInt(data.sent_schema_tokens);\n  const rawFull = strictNonNegativeInt(data.full_schema_tokens);\n  const validCounts = rawSent !== null && rawFull !== null && rawSent <= rawFull;\n  const sentSchemaTokens = validCounts ? rawSent : 0;\n  const fullSchemaTokens = validCounts ? rawFull : 0;\n  const savedTokens = fullSchemaTokens - sentSchemaTokens;\n  const reductionPct = fullSchemaTokens === 0 ? 0 : Math.round((savedTokens / fullSchemaTokens) * 1000) / 10;\n\n  const catalogByName = new Map<string, CaveTool>();\n  for (const tool of catalog) {\n    if (typeof tool.name !== \"string\" || tool.name.trim() === \"\" || catalogByName.has(tool.name)) {\n      throw new Error(\"tool catalog names must be non-empty and unique\");\n    }\n    catalogByName.set(tool.name, tool);\n  }\n  if (!Array.isArray(data.tools)) throw new Error(\"tool search response tools must be an array\");\n  const returnedNames = new Set<string>();\n  const selectedTools = data.tools.map((wire: unknown) => {\n    const name = wire !== null && typeof wire === \"object\" && typeof (wire as Record<string, unknown>)[\"name\"] === \"string\"\n      ? (wire as Record<string, unknown>)[\"name\"] as string\n      : \"\";\n    const local = catalogByName.get(name);\n    if (!local || returnedNames.has(name)) throw new Error(\"tool search response contained an unknown or duplicate tool\");\n    returnedNames.add(name);\n    return local;\n  });\n\n  return {\n    sessionId: typeof data.session_id === \"string\" ? data.session_id : undefined,\n    tools: selectedTools,","sourceCodeStart":1602,"sourceCodeEnd":1638,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/sdk/typescript/src/index.ts#L1602-L1638","documentation":"Error \"tool catalog names must be non-empty and unique\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:1620 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give every catalog tool a non-empty, unique name."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}