Skip to content

fix(server): log upstream 5xx bodies from proxied workspace requests - #40135

Open
jamesmurdza wants to merge 1 commit into
anomalyco:devfrom
jamesmurdza:fix/workspace-proxy-log-5xx-bodies
Open

fix(server): log upstream 5xx bodies from proxied workspace requests#40135
jamesmurdza wants to merge 1 commit into
anomalyco:devfrom
jamesmurdza:fix/workspace-proxy-log-5xx-bodies

Conversation

@jamesmurdza

@jamesmurdza jamesmurdza commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Related to #39471, #36826

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The workspace proxy streams the upstream response straight through. When a remote sandbox returns a 5xx, the detailed cause is only logged inside the sandbox, so a maintainer tailing the host's log sees nothing — just an error surfacing on the client with no local trace to correlate it against.

For 5xx responses only, this buffers the (small) error body, logs it on the host via Effect.logError with the url/method/status, and then forwards the body unchanged with its original content-type. Buffering is fine here because these are short error payloads, not streamed content, and preserving the content-type means the client can still parse the structured error (e.g. its ref). Success/2xx responses keep streaming exactly as before.

How did you verify your code works?

  • Pointed the proxy at a workspace endpoint that returns a 500 with a JSON error body; confirmed the body now appears in the host log and the client still receives the same status + body + content-type it did before.
  • Confirmed non-5xx responses are untouched (still streamed, no buffering).

Screenshots / recordings

N/A — not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

A 5xx from a remote workspace sandbox previously passed through the
proxy opaquely: the detailed cause was logged only inside the sandbox,
so the host tailing its own log saw nothing. Buffer the (small) error
body for 5xx responses, log it on the host, and forward it unchanged
with its original content-type so the client can still read the
structured error ref.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant