{"record":{"id":"76c4446e4ca9b744","repo":"ruvnet/ruflo","slug":"cohere-response-status","errorCode":"COHERE_${response.status}","errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"exception","errorClass":"LLMProviderError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/providers/src/cohere-provider.ts","lineNumber":413,"sourceCode":"  private async handleErrorResponse(response: Response): Promise<never> {\n    const errorText = await response.text();\n    let errorData: { message?: string };\n\n    try {\n      errorData = JSON.parse(errorText);\n    } catch {\n      errorData = { message: errorText };\n    }\n\n    const message = errorData.message || 'Unknown error';\n\n    switch (response.status) {\n      case 401:\n        throw new AuthenticationError(message, 'cohere', errorData);\n      case 429:\n        throw new RateLimitError(message, 'cohere', undefined, errorData);\n      default:\n        throw new LLMProviderError(\n          message,\n          `COHERE_${response.status}`,\n          'cohere',\n          response.status,\n          response.status >= 500,\n          errorData\n        );\n    }\n  }\n}\n","sourceCodeStart":395,"sourceCodeEnd":424,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/providers/src/cohere-provider.ts#L395-L424","documentation":"CohereProvider's fallback mapping for any HTTP status other than 401/429: LLMProviderError with code COHERE_<status>, retryable=true only when status >= 500. The message is whatever Cohere's JSON error body contained ('Unknown error' if the body was not JSON).","triggerScenarios":"complete()/streamComplete() receiving a 400 (invalid request or bad model name), 404 (unknown model), or a 5xx from Cohere infrastructure.","commonSituations":"Unsupported parameter or oversized payload (400); model id typo like 'command-r' vs 'command-r-plus' (404); a Cohere-side incident returning 500/502/503.","solutions":["Inspect error.statusCode and error.details (the parsed body) - the Cohere message names the actual problem","For 4xx: fix the request (exact model id, supported parameters, payload size); retrying will not help","For 5xx (retryable=true): retry with backoff or fail over to another provider via the ProviderManager","If 5xx persists, check Cohere status and community channels for incidents"],"exampleFix":"// before\nconst res = await provider.complete(req); // COHERE_400 surfaces raw\n\n// after - branch on retryability\ntry {\n  const res = await provider.complete(req);\n} catch (e) {\n  if (e instanceof LLMProviderError && e.retryable) {\n    return retryWithBackoff(() => provider.complete(req));\n  }\n  throw e; // 4xx: fix the request instead of retrying\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { LLMProviderError, isLLMProviderError } from './types.js';\nfunction isCohereApiError(e: unknown): e is LLMProviderError {\n  return isLLMProviderError(e) && e.provider === 'cohere' && e.code.startsWith('COHERE_');\n}","tryCatchPattern":"try {\n  return await provider.complete(req);\n} catch (e) {\n  if (isCohereApiError(e)) {\n    if (e.retryable) return retryWithBackoff(() => provider.complete(req)); // 5xx only\n    throw new RequestError(`cohere rejected request (${e.statusCode}): ${e.message}`, { cause: e }); // 4xx: fix payload\n  }\n  throw e;\n}","preventionTips":["Branch on error.retryable (true only for status >= 500) instead of retrying everything","Log e.statusCode and e.details for 4xx - Cohere's message names the invalid field","Validate model ids against provider.listModels() before sending"],"tags":["http-error","cohere","api-error","status-mapping"],"backgroundTag":"http-error-response","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}