{"record":{"id":"678615dc4b020497","repo":"openclaw/openclaw","slug":"cohere-model-catalog-response-must-contain-models","errorCode":null,"errorMessage":"Cohere model catalog response must contain models[]","messagePattern":"Cohere model catalog response must contain models\\[\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/cohere/provider-catalog.ts","lineNumber":15,"sourceCode":"import type { OpenAICompatibleModelDiscoveryOptions } from \"openclaw/plugin-sdk/provider-catalog-live-runtime\";\nimport { COHERE_BASE_URL } from \"./models.js\";\n\nexport const COHERE_LIVE_MODEL_DISCOVERY: OpenAICompatibleModelDiscoveryOptions = {\n  endpointUrl: {\n    url: \"https://api.cohere.com/v1/models?endpoint=chat&page_size=1000\",\n    requireBaseUrl: COHERE_BASE_URL,\n  },\n  readRows: (body) => {\n    if (\n      !body ||\n      typeof body !== \"object\" ||\n      !Array.isArray((body as { models?: unknown }).models)\n    ) {\n      throw new Error(\"Cohere model catalog response must contain models[]\");\n    }\n    return (body as { models: unknown[] }).models.flatMap((row) => {\n      if (!row || typeof row !== \"object\" || Array.isArray(row)) {\n        return [];\n      }\n      const record = row as Record<string, unknown>;\n      const modelId = typeof record.name === \"string\" ? record.name.trim() : \"\";\n      return modelId ? [{ ...record, id: modelId, active: record.is_deprecated !== true }] : [];\n    });\n  },\n};\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/cohere/provider-catalog.ts#L1-L27","documentation":"Thrown by the Cohere provider catalog readRows() parser when the live model-discovery HTTP response body is missing a top-level models array. The discovery endpoint (api.cohere.com/v1/models?endpoint=chat&page_size=1000) is expected to return { models: [...] }; any other shape (error object, HTML, paginated wrapper, empty) fails fast rather than silently registering zero models.","triggerScenarios":"Cohere API returned an error envelope (e.g. { message: 'unauthorized' }) instead of a models list. API version change altered the response shape. Auth token invalid so the endpoint returned a JSON error object. Rate-limit or maintenance response lacking the models field.","commonSituations":"Expired or invalid Cohere API key causing an auth-error JSON body. Cohere API schema evolution. Network proxy returning a different envelope. Endpoint URL modified or the query param (endpoint=chat) dropped.","solutions":["Verify the Cohere API key is valid and has access to the models endpoint.","Confirm the discovery URL still uses endpoint=chat&page_size=1000 and that Cohere has not changed the response contract.","Inspect the raw API response (status code + body) to identify whether it is an auth error, rate limit, or schema change.","If the API contract changed, update readRows() to match the new shape or pin a compatible API version."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function cohereModelsReachable(apiKey) {\n  const res = await fetch(\"https://api.cohere.com/v1/models?endpoint=chat&page_size=1000\", {\n    headers: { Authorization: `Bearer ${apiKey}` },\n  });\n  const body = await res.json().catch(() => null);\n  return res.ok && Array.isArray(body?.models);\n}","typeGuard":"function isCohereModelsResponse(body) {\n  return !!body && typeof body === \"object\" && !Array.isArray(body) && Array.isArray(body.models);\n}","tryCatchPattern":null,"preventionTips":["Validate the Cohere API key and models endpoint reachability before triggering model discovery.","Log the raw response status/body when discovery fails to distinguish auth errors from schema changes.","Pin a compatible API version if Cohere changes the response contract."],"tags":["cohere","model-discovery","api-contract","auth"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}