opencode-openai-codex-auth icon indicating copy to clipboard operation
opencode-openai-codex-auth copied to clipboard

fix: robust SSE parsing for multiline JSON and fallback handling

Open harshav167 opened this issue 1 week ago • 1 comments

Summary

Fixes SSE parsing issues when Codex API returns non-standard SSE formats.

Changes

  • Handle data: with or without space after colon (both data: {...} and data:{...})
  • Support multiline JSON split across multiple data: lines
  • Graceful fallback chain: finalResponselastResponseLikelastEvent
  • Skip malformed JSON lines while preserving valid subsequent events
  • Add tests for edge cases (no-space colon, multiline data)

Files Changed

  • lib/request/response-handler.ts - Enhanced SSE parsing logic
  • test/response-handler.test.ts - Added edge case tests

harshav167 avatar Jan 06 '26 03:01 harshav167

Thanks! I haven’t been able to reproduce yet. If you can share a failing raw SSE payload or ~/.opencode/logs/codex-plugin/request-*-response.json, I’ll validate and fold this in.

numman-ali avatar Jan 09 '26 14:01 numman-ali