Skip to content

fix(proxy): distinguish upstream failures from routing failures in proxy ErrorHandler - #3692

Open
AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:fix/proxy-error-handler-messaging
Open

AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:fix/proxy-error-handler-messaging

Conversation

@AdaAibaby

Copy link
Copy Markdown
Contributor

What & why

The reverse-proxy ErrorHandler in packages/shared/pkg/proxy/pool/client.go returned the same "Failed to route request to sandbox" message for two unrelated cases:

  • Routing failure — destination not resolved (getDestination !ok, or empty Host) → 500.
  • Upstream/transport failure — destination already resolved, but the request to envd/orchestrator failed → 502 (final fallback).

Operators could not tell a real routing problem apart from ordinary client-caused noise (a weak/CGNAT link dropping a large POST /files upload, or an envd answering 5xx). See #3691 for production detail.

Changes

  • Distinct 502 message. The upstream/transport fallback now returns "Failed to reach sandbox (upstream connection error)" with 502, leaving the 500 routing-failure messages untouched. The two classes are now unambiguous in both logs and client responses.
  • Downgrade client-caused disconnects to Warn. context.Canceled, syscall.ECONNRESET and io.EOF are client/network aborts, not server faults, so they log at Warn instead of Error and stop drowning real upstream errors in ERROR-level noise. (Extends the existing context.Canceled special-case to also cover reset/EOF, and applies it regardless of port.)

No behavioral change to routing, status codes for the routing-failure paths, or the closed-port path.

Testing

  • gofmt clean.
  • go build ./pkg/proxy/pool/ passes.

Closes #3691

…oxy ErrorHandler

The proxy ErrorHandler returned the same "Failed to route request to
sandbox" message for two unrelated cases: a genuine routing failure
(destination not resolved, 500) and an upstream/transport failure after
the destination was already resolved (502). Operators reading the logs
could not tell a real routing problem apart from a client that dropped a
large upload or an envd that answered 5xx.

- The 502 path now returns a distinct message ("Failed to reach sandbox
  (upstream connection error)"), so the 500 routing failures and the 502
  upstream failures are unambiguous in both logs and client responses.
- Client-caused disconnects (context.Canceled, ECONNRESET, io.EOF) are
  logged at Warn instead of Error. A weak/CGNAT link dropping a large
  POST /files upload, or an SDK giving up mid-request, is not a server
  fault and should not drown real upstream errors in ERROR-level noise.

This branch has not been deployed

No deployments
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.

proxy: ErrorHandler returns "Failed to route request to sandbox" for both routing (500) and upstream (502) failures

2 participants