Skip to content

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

Open

Description

@AdaAibaby

Summary

In packages/shared/pkg/proxy/pool/client.go, the reverse-proxy ErrorHandler returns the same client-facing message — "Failed to route request to sandbox" — for two unrelated failure classes:

  1. Genuine routing failure (getDestination returns !ok, or r.Host == "") → 500. The proxy truly could not resolve which sandbox the request belongs to.
  2. Upstream/transport failure after the destination was already resolved (final fallback) → 502. The sandbox was resolved (sandbox.id, target_hostname, target_port are all present); the proxy just failed to reach/complete the request to envd/orchestrator.

Because both say "Failed to route request to sandbox", operators cannot tell a real routing outage apart from ordinary, client-caused noise.

What this looks like in production

Observed on a production deployment, all on POST /files (envd port 49983):

  • sandbox error handler called with read tcp ...: read: connection reset by peer, content_length: ~51MB, CGNAT client IP — i.e. a client dropping a large upload.
  • Reverse proxy error with status_code: 500 — i.e. envd itself answered 5xx.

Zero actual failed to get routing target / proxy request without sandbox in the same window — so nothing was ever truly a routing failure, yet the message said so.

Proposed fix

  • Give the 502 (upstream/transport) path a distinct message so 500 routing failures and 502 upstream failures are unambiguous in logs and client responses.
  • Downgrade client-caused disconnects (context.Canceled, ECONNRESET, io.EOF) from Error to Warn, so a weak/CGNAT link dropping a large upload or an SDK giving up mid-request does not drown real upstream errors in ERROR-level noise.

PR attached.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions