{"record":{"id":"a6f527f9b785417e","repo":"ruvnet/ruflo","slug":"upstream-error-err-message","errorCode":null,"errorMessage":"Upstream error: ${err.message}","messagePattern":"Upstream error: (.+?)","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"ruflo/src/mcp-bridge/index.js","lineNumber":1686,"sourceCode":"    res.setHeader(\"Content-Type\", upstream.headers.get(\"content-type\") || \"application/json\");\n\n    if (req.body?.stream && upstream.body) {\n      const reader = upstream.body.getReader();\n      const decoder = new TextDecoder();\n      try {\n        while (true) {\n          const { done, value } = await reader.read();\n          if (done) break;\n          res.write(decoder.decode(value, { stream: true }));\n        }\n      } catch (e) { /* stream closed */ }\n      finally { res.end(); }\n    } else {\n      res.send(await upstream.text());\n    }\n  } catch (err) {\n    console.error(`Proxy error [${providerName}/${model}]:`, err.message);\n    res.status(502).json({ error: { message: `Upstream error: ${err.message}` } });\n  }\n});\n\n// =============================================================================\n// MODELS & HEALTH\n// =============================================================================\n\nconst KNOWN_MODELS = [\n  \"gemini-2.5-pro\", \"gemini-2.5-flash\",\n  \"gpt-4.1\", \"gpt-4.1-mini\", \"gpt-4o\", \"gpt-4o-mini\",\n  \"o3-mini\", \"o1-mini\",\n];\n\napp.get(\"/models\", (_, res) => {\n  res.json({ object: \"list\", data: KNOWN_MODELS.map(id => ({ id, object: \"model\", owned_by: \"system\" })) });\n});\n\napp.get(\"/health\", (_, res) => {","sourceCodeStart":1668,"sourceCodeEnd":1704,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/ruflo/src/mcp-bridge/index.js#L1668-L1704","documentation":"The chat-completions proxy's upstream fetch rejected or returned an error (network failure, non-2xx, or provider rejection). The catch block wraps the upstream's own err.message with the 'Upstream error' prefix and returns the error response to the client; the root cause text comes from the provider call.","triggerScenarios":"Thrown at ruflo/src/mcp-bridge/index.js:1686 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the upstream provider error message; retry transient failures with backoff.","Verify provider credentials, quotas, and request shape against the provider's API documentation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}