{"record":{"id":"31737e0604ca4805","repo":"ruvnet/ruflo","slug":"string-err-instanceof-error-err-message-err","errorCode":null,"errorMessage":"String(err instanceof Error ? err.message : err)","messagePattern":"String\\(err instanceof Error \\? err\\.message : err\\)","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/browser-intent-tools.ts","lineNumber":247,"sourceCode":"          method: req.method,\n          headers: {\n            'content-type': 'application/json',\n            // The real key is injected here, server-side, and nowhere else —\n            // whatever Authorization header the page-context request carried\n            // (the placeholder) is discarded.\n            authorization: `Bearer ${real.apiKey}`,\n          },\n          body: body.length > 0 ? body : undefined,\n        })\n          .then(async (upstream) => {\n            const text = await upstream.text();\n            res.writeHead(upstream.status, {\n              'content-type': upstream.headers.get('content-type') || 'application/json',\n            });\n            res.end(text);\n          })\n          .catch((err: unknown) => {\n            res.writeHead(502, { 'content-type': 'application/json' });\n            res.end(JSON.stringify({ error: { message: String(err instanceof Error ? err.message : err) } }));\n          });\n      });\n    });\n    server.on('error', reject);\n    server.listen(0, '127.0.0.1', () => {\n      const addr = server.address();\n      const port = typeof addr === 'object' && addr ? addr.port : 0;\n      resolve({\n        url: `http://127.0.0.1:${port}`,\n        close: () => {\n          try { server.close(); } catch { /* best-effort */ }\n        },\n      });\n    });\n  });\n}\n","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/mcp-tools/browser-intent-tools.ts#L229-L265","documentation":"Diagnostic in startLocalLLMProxy: expression that normalizes a caught upstream/proxy error into its message string (err.message when Error, otherwise the value itself) so the proxy can log or return the failure reason for a proxied browser-intent LLM request.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/mcp-tools/browser-intent-tools.ts:247 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Propagate the real underlying error message instead of a placeholder; log the full stack for diagnosis."],"exampleFix":null,"handlingStrategy":"fallback","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"}