{"record":{"id":"77417d95a3bc6f2d","repo":"diegosouzapw/OmniRoute","slug":"omniroute-upstream-status-errtext-77417d","errorCode":null,"errorMessage":"OmniRoute ${upstream.status}: ${errText}","messagePattern":"OmniRoute (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mitm/handlers/kiro.ts","lineNumber":36,"sourceCode":"  async intercept(\n    req: IncomingMessage,\n    res: ServerResponse,\n    body: Buffer,\n    mappedModel: string,\n  ): Promise<void> {\n    const startedAt = this.now();\n    const intercepted = await this.hookBufferStart(req, body, mappedModel);\n\n    try {\n      const payload = JSON.parse(body.toString());\n      payload.model = mappedModel;\n\n      const upstreamStart = this.now();\n      const upstream = await this.fetchRouter(payload, \"/v1/messages\", req.headers);\n\n      if (!upstream.ok) {\n        const errText = await upstream.text().catch(() => \"\");\n        throw new Error(`OmniRoute ${upstream.status}: ${errText}`);\n      }\n\n      let collected = \"\";\n      await this.pipeSSE(upstream, res, (chunk) => {\n        collected += chunk.toString();\n      });\n\n      const total = this.now() - startedAt;\n      this.hookBufferUpdate(intercepted, {\n        status: upstream.status,\n        responseHeaders: Object.fromEntries(upstream.headers.entries()),\n        responseBody: collected,\n        responseSize: Buffer.byteLength(collected),\n        proxyLatencyMs: upstreamStart - startedAt,\n        upstreamLatencyMs: total - (upstreamStart - startedAt),\n      });\n    } catch (err) {\n      await this.hookBufferError(intercepted, err);","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/mitm/handlers/kiro.ts#L18-L54","documentation":"MITM intercept for the Kiro client proxied the rewritten payload (model already mapped) to OmniRoute's own /v1/messages endpoint via fetchRouter and the router answered non-2xx; the router's status code and (possibly empty) error text are interpolated. The Kiro-facing side re-raises the router's failure — root cause is inside OmniRoute routing/auth, or the mapped model/target is unavailable; the catch in the handler turns it into an error response for the client.","triggerScenarios":"Thrown at src/mitm/handlers/kiro.ts:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the router's own logs for the same request to see which upstream/auth stage failed for /v1/messages","Verify the mapped model is available and the Kiro connection credentials are valid in OmniRoute","Check upstream.text() content when non-empty — it carries the router's sanitized error body","If the failure is transient (upstream 5xx/timeout), let the client retry or enable fallback routing for that model"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}