Fix upstream error status codes being converted to 500 in forward proxy#5721
Draft
Fix upstream error status codes being converted to 500 in forward proxy#5721
Conversation
…tus codes Fixes SENTRY-5K7H When the integration proxy endpoint (Relay's forward endpoint) forwards requests to upstream services like GitHub and those services return error status codes (e.g. 403 Forbidden due to IP allow-list restrictions), Relay was converting those errors to 500 Internal Server Error responses instead of passing through the actual status code. The root cause was in `UpstreamRequestError::IntoResponse` where the wildcard catch-all `_ => StatusCode::INTERNAL_SERVER_ERROR` was matching `ResponseError(status, _)` and `RateLimited(_)` variants, discarding the actual upstream status code. Fix: Explicitly handle `ResponseError` and `RateLimited` before the wildcard so that: - `ResponseError(status, _)` returns the actual upstream HTTP status code - `RateLimited(_)` returns 429 Too Many Requests - Internal errors (`NoCredentials`, `ChannelClosed`, `AuthDenied`) still return 500 via the wildcard Co-authored-by: JoshFerge <1976777+JoshFerge@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [SENTRY-5K7H] Fix integration proxy endpoint error handling
Fix upstream error status codes being converted to 500 in forward proxy
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UpstreamRequestError::IntoResponsehad a catch-all wildcard_ => 500that swallowedResponseError(status, _)andRateLimited(_), causing Relay to return 500 to callers even when the upstream returned a meaningful error like a GitHub 403 (e.g. IP allow-list restriction). The actual error was completely masked.Changes
relay-server/src/services/upstream.rs: Add explicit arms before the wildcard inUpstreamRequestError::IntoResponse:ResponseError(status, _)→ forward the upstream status codeRateLimited(_)→ 429_now only covers true internal failures (NoCredentials,ChannelClosed,AuthDenied)tests/integration/test_forwarding.py: Addtest_forwarding_error_status_codesparametrized over 403, 404, 429, 500, 503 to assert Relay does not convert upstream error responses to 500.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
chromium.googlesource.com/usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED -o crypto/engine/libcrypto-lib-eng_pkey.o /tmp/cc5hatzm.s lib/rustlib/x86_providers/common/include stable-x86_64-un-I derive.487c4a665cmp derive.487c4a665crypto/engine/libcrypto-lib-eng_dyn.d.tmp derive.487c4a665crypto/engine/libcrypto-lib-eng_dyn.d pto/ec/libcrypto-o f232�� derive.487c4a665/tmp/ccKbcDby.s -I rking/target/debug/deps/rustcsLeFEz/symbols.o b_cipher.d.tmp; \ else \ mv crypto/engine/libcrypto-lib-tb_cipher.d.tmp crypto/engine/libcrypt rking/target/deb-I rking/target/deb. rking/target/deb-I(dns block)/usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED -DSHA1_ASM lib/�� ug/deps/libheck--I lib/rustlib/x86_providers/common/include o \ rm -f crypto//usr/libexec/gcc/x86_64-linux-gnu/13/cc1 derive.487c4a665-quiet derive.487c4a665-I ONT5 -DOPENSSL_C. f232�� derive.487c4a665include -fdata-sections rking/target/debproviders/common/include rking/target/deb/bin/sh rking/target/deb-c rking/target/debif cmp crypto/engine/libcrypto-lib-eng_pkey.d.tmp crypto/engine/libcrypto-lib-en-DAES_ASM ne/libcrypto-li(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.