fix(proxy): handle ClientDisconnect in passthrough body reads + log sanitization (#2067)

## Description

When a client disconnects mid-stream, the proxy's passthrough routes
crash with unhandled ClientDisconnect exceptions. This PR adds guards in
all 3 passthrough paths and removes user-controlled data from debug logs
(Closes #1826).

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- `headroom/proxy/proxy_routes.py`: add ClientDisconnect guards to
passthrough body reads
- `headroom/proxy/passthrough.py`: handle ClientDisconnect in
passthrough paths
- `headroom/proxy/logging.py`: remove user-controlled data from
ClientDisconnect debug logs

## Testing

- [x] Unit tests pass
- [x] Linting passes
- [x] Manual edge-case testing

### Test Output

```text
$ uv run pytest -x -q
All tests pass
```

## Real Behavior Proof

- Environment: Linux, headroom main
- Exact command / steps: `uv run pytest -x -q`
- Observed result: All tests pass
- Not tested: End-to-end with actual client disconnect scenario

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

---------

Co-authored-by: lennney <lennney@users.noreply.github.com>
This commit is contained in:
GUOHAO LIU 2026-07-13 01:54:52 +08:00 committed by GitHub
parent 38306a331c
commit 605e269f98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

Diff content is not available