{"record":{"id":"25c6c4dcaa210ec7","repo":"paperclipai/paperclip","slug":"opencode-event-stream-returned-http-response-sta","errorCode":null,"errorMessage":"OpenCode event stream returned HTTP ${response.status}","messagePattern":"OpenCode event stream returned HTTP (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/drivers/opencode/opencode-server-driver.ts","lineNumber":1160,"sourceCode":"        },\n      },\n      { turnId, itemId: request.itemId },\n    );\n  }\n\n  async #pumpEvents(): Promise<void> {\n    let attempts = 0;\n    while (!this.#closed && !this.#abort.signal.aborted) {\n      try {\n        const response = await this.#fetch(`${this.#runtime.baseUrl}/event`, {\n          headers: {\n            Authorization: this.#runtime.authHeader,\n            Accept: \"text/event-stream\",\n          },\n          signal: this.#abort.signal,\n        });\n        if (!response.ok || !response.body)\n          throw new Error(\n            `OpenCode event stream returned HTTP ${response.status}`,\n          );\n        const outboundFrameId = this.#runtime.trace?.frame({\n          direction: \"client_to_provider\",\n          raw: \"\",\n          transport: \"http_sse\",\n          nativeMethod: \"GET /event\",\n        });\n        if (outboundFrameId) {\n          this.#runtime.trace?.interpretation({\n            frameId: outboundFrameId,\n            stage: \"typescript_opencode_http_transport\",\n            ruleId: \"opencode.http.GET_event\",\n            disposition: \"operator_only\",\n            reason: \"Opened the OpenCode server-sent event stream\",\n          });\n        }\n        for await (const frame of parseSseFrames(response.body)) {","sourceCodeStart":1142,"sourceCodeEnd":1178,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/src/drivers/opencode/opencode-server-driver.ts#L1142-L1178","documentation":"Thrown when the driver opens the OpenCode server's SSE event stream and the HTTP response is not ok or has no body. The message embeds the HTTP status so the developer can see whether the endpoint rejected auth, was not found, or the server is unhealthy.","triggerScenarios":"The driver issues a GET for the event stream with Authorization/Accept: text/event-stream headers and receives a non-2xx status (e.g. 401, 404, 502), or a 200 without a readable body.","commonSituations":"Wrong or expired authHeader after the server restarted with new credentials; proxy/load balancer returning 502/503; OpenCode server version whose event endpoint path differs; server crashed mid-startup.","solutions":["Check the HTTP status in the message: 401/403 means fix the authHeader; 404 means the event endpoint path changed (check server version).","Verify the OpenCode server process is alive and healthy at the configured base URL before opening the stream.","Confirm any proxy in front of OpenCode supports streaming responses and is not stripping the SSE body.","Retry session startup — the driver already retries up to 3 times, so persistent failure means a configuration issue."],"exampleFix":"// before\nconst res = await fetch(`${baseUrl}/event`, { headers });\n\n// after\nconst res = await fetch(`${baseUrl}/event`, { headers });\nif (res.status === 401) {\n  throw new Error(\"Event stream auth rejected — refresh authHeader from server health/startup\");\n}","handlingStrategy":"retry","validationCode":"const health = await fetch(`${baseUrl}/health`);\nif (!health.ok) throw new Error(`OpenCode server unhealthy: HTTP ${health.status}`);","typeGuard":null,"tryCatchPattern":"try {\n  await openStream();\n} catch (e) {\n  if (e instanceof Error && /event stream returned HTTP (401|403)/.test(e.message)) {\n    authHeader = await refreshAuth(); // re-auth before retrying\n  } else if (/event stream returned HTTP (502|503|504)/.test(e.message)) {\n    await backoff(); // transient upstream — retry with backoff\n  }\n}","preventionTips":["Health-check the server before opening the event stream","Keep the authHeader in sync with server restarts","Verify proxies between client and server support SSE streaming"],"tags":["sse","http","streaming","network"],"backgroundTag":"http-error-response","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}