Skip to content

fix(proxy): decode ArrayBuffer bodies for Responses WebSocket - #1432

Open
ROOOO wants to merge 1 commit into
ding113:devfrom
ROOOO:fix/responses-ws-arraybuffer
Open

fix(proxy): decode ArrayBuffer bodies for Responses WebSocket#1432
ROOOO wants to merge 1 commit into
ding113:devfrom
ROOOO:fix/responses-ws-arraybuffer

Conversation

@ROOOO

@ROOOO ROOOO commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Decode raw ArrayBuffer request bodies before Responses WebSocket forwarding.
  • Add regression coverage proving Remote Compaction v2 remains on WebSocket.

Problem

Remote Compaction v2 requests carrying previous_response_id could skip upstream Responses WebSocket forwarding and fall back to HTTP. The upstream HTTP endpoint rejects that continuation parameter.

Related

Root cause

Raw passthrough bodies are stored as ArrayBuffer values, while decodeRequestBodyAsJson only handled strings, Buffers, and Uint8Arrays. Decoding therefore returned null and the WebSocket attempt was skipped.

Impact

Eligible Remote Compaction v2 requests continue through the upstream Responses WebSocket path instead of failing after HTTP fallback. Other request-body shapes retain existing behavior.

Validation

  • bun run build — passed
  • bun run lint — passed
  • bun run lint:fix — passed; no fixes
  • bun run typecheck — passed
  • bunx vitest run tests/unit/proxy/proxy-forwarder-raw-passthrough-regression.test.ts — passed (5 tests)
  • bun run test — 8529 passed, 13 skipped, 1 failed. The failure is the existing LanguageSwitcher > keeps the pending refresh after remount when sessionStorage is blocked assertion; its test file is unchanged from upstream/dev, and the isolated rerun reproduces the same failure.

Greptile Summary

This PR adds JSON decoding for raw ArrayBuffer request bodies so eligible Remote Compaction v2 requests can continue through the Responses WebSocket path instead of falling back to HTTP.

  • Decodes ArrayBuffer bodies as UTF-8 alongside existing string, Buffer, and Uint8Array handling.
  • Adds regression coverage verifying the decoded body reaches the Responses WebSocket adapter and HTTP fallback is not invoked.

Confidence Score: 5/5

The PR appears safe to merge, with the focused change correctly restoring WebSocket forwarding for raw ArrayBuffer request bodies.

Raw-passthrough bodies are normalized to native ArrayBuffers, the new branch decodes their complete byte range consistently with existing body types, and the regression test verifies that the resulting JSON reaches the WebSocket adapter without HTTP fallback.

Important Files Changed

Filename Overview
src/app/v1/_lib/proxy/forwarder.ts Adds the missing ArrayBuffer decoding branch using the same UTF-8 behavior as the existing binary body variants; no actionable issue found.
tests/unit/proxy/proxy-forwarder-raw-passthrough-regression.test.ts Adds focused WebSocket-path regression coverage that exercises the real body decoder and asserts HTTP fallback is avoided.

Reviews (1): Last reviewed commit: "fix(proxy): decode ArrayBuffer bodies fo..." | Re-trigger Greptile

Context used:

Symptom:
- Remote Compaction v2 requests with previous_response_id skipped the upstream WebSocket path and fell back to HTTP, where they were rejected.

Cause:
- Raw passthrough request bodies are stored as ArrayBuffer values.
- Responses WebSocket body decoding did not support ArrayBuffer, so the upstream WebSocket frame was never sent.

Solution:
- Decode ArrayBuffer request bodies before constructing the upstream WebSocket frame.
- Add regression coverage ensuring Remote Compaction v2 continues over WebSocket.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d65b6ae-9c05-479c-85b9-4ebd91d3b3ba

📥 Commits

Reviewing files that changed from the base of the PR and between 5424991 and 40a2d9d.

📒 Files selected for processing (2)
  • src/app/v1/_lib/proxy/forwarder.ts
  • tests/unit/proxy/proxy-forwarder-raw-passthrough-regression.test.ts

📝 Walkthrough

Walkthrough

该变更支持将 ArrayBuffer 请求体解码为 JSON,并验证启用 remote_compaction_v2 时通过 Responses WebSocket 转发请求。

Changes

ArrayBuffer 代理转发

Layer / File(s) Summary
ArrayBuffer 请求体解码
src/app/v1/_lib/proxy/forwarder.ts
decodeRequestBodyAsJsonArrayBuffer 请求体转换为 UTF-8 文本,并继续进行 JSON 解析。其他请求体类型和解析失败行为不变。
Responses WebSocket 转发回归验证
tests/unit/proxy/proxy-forwarder-raw-passthrough-regression.test.ts
新增 WebSocket mock 和回归测试。测试验证请求对象、client-ws-session、SSE 响应,以及未调用 HTTP fallback。

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 40a2d

This localized fix is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Suggested reviewers: ding113, tesgth032, brisbanehuang

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 标题准确概括了为 Responses WebSocket 解码 ArrayBuffer 请求体的主要修复。
Description check ✅ Passed 描述说明了问题、根因、修复内容、测试结果及已知的既有测试失败。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug Something isn't working area:core area:OpenAI labels Aug 14, 2026
@ROOOO
ROOOO marked this pull request as ready for review August 14, 2026 13:56
@github-actions github-actions Bot added the size/S Small PR (< 200 lines) label Aug 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

No significant issues identified in this PR.

PR Size: S

  • Lines changed: 80
  • Files changed: 2

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean
  • Type safety - Clean
  • Documentation accuracy - Clean
  • Test coverage - Adequate
  • Code clarity - Good

Automated review by Claude AI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core area:OpenAI bug Something isn't working size/S Small PR (< 200 lines)

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant