{"record":{"id":"7af1053a3e6f055a","repo":"koala73/worldmonitor","slug":"method-post-http-postresp-status","errorCode":null,"errorMessage":"${method} POST HTTP ${postResp.status}","messagePattern":"(.+?) POST HTTP (.+?)","errorType":"exception","errorClass":null,"httpStatus":422,"severity":"error","filePath":"api/mcp-proxy.ts","lineNumber":485,"sourceCode":"// name-shaped trampoline that cannot match the spelling it has not seen.\nconst CROSS_ORIGIN_SAFE_HEADERS = new Set(['content-type', 'accept', 'user-agent']);\n\nfunction redirectTargetFor(response, fromUrl) {\n  const location = response.headers.get('location');\n  if (!location) return null;\n  let next;\n  try {\n    next = new URL(location, fromUrl);\n  } catch {\n    return null;\n  }\n  // assertServerUrlSafe vets the host but not the scheme, and the entry-point\n  // https check in validateServerUrl never sees a redirect target — so a\n  // downgrade to http:// has to be refused right here.\n  if (next.protocol !== 'https:') return null;\n  return next;\n}\n\nfunction stripToCrossOriginSafeHeaders(headers) {\n  const out = {};\n  for (const [key, value] of Object.entries(headers)) {\n    if (CROSS_ORIGIN_SAFE_HEADERS.has(key.toLowerCase())) out[key] = value;\n  }\n  return out;\n}\n\nasync function postJson(url, body, headers, sessionId) {\n  const h = { ...headers };\n  if (sessionId) h['Mcp-Session-Id'] = sessionId;\n  const payload = JSON.stringify(body);\n  let target = url;\n  let outboundHeaders = h;\n  // ONE deadline for the whole exchange, not one per hop — a per-hop signal\n  // would quietly hand a redirecting upstream twice the budget every other\n  // dispatch gets.\n  const signal = AbortSignal.timeout(TIMEOUT_MS);","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/api/mcp-proxy.ts#L467-L503","documentation":"Thrown by SseSession.send when the POST of a JSON-RPC message to the server-advertised endpoint URL returned a non-2xx HTTP status. The SSE stream is up and the endpoint URL was re-validated against SSRF rules, but the server rejected the message POST itself (expired session, auth, or upstream error). The pending RPC deferred is rejected with this error and the timeout timer is cleared.","triggerScenarios":"Thrown at api/mcp-proxy.ts:482 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the status in the message: 404 commonly means the session/endpoint expired — reconnect to get a fresh endpoint event","Ensure auth headers are applied to the POST as well as the SSE stream","Retry the whole SSE session (connect + send) for transient 5xx failures"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e586b8b4b80f595aa7ece295eec10d76f2921240","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}