fix(client): don't KeyError when a proxy is configured#555
fix(client): don't KeyError when a proxy is configured#555RapidPoseidon wants to merge 1 commit intomainfrom
Conversation
`_get_session_defaults` built `client_kwargs` with only `verify` and
`limits`, then inside the `if self.configuration.proxy` branch called
`client_kwargs.pop("headers")` — which always raised `KeyError: 'headers'`
because the key had never been inserted. Any user behind a corporate
proxy was hard-bricked on the first call.
Switch to `client_kwargs.get("headers") or {}` and only set the merged
dict when there are proxy_headers to merge. `proxy` itself was fine; the
only broken path was the headers merge.
Also mirrored into `openapi/templates/rest.mustache`.
Session: https://session-bc38cc85.poseidon.rapidata.internal/
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: lino <lino@rapidata.ai>
Code ReviewOverviewThis PR fixes a regression that hard-bricks any user behind a corporate proxy. The root cause is clear: What's Good
Issues & Suggestions
|
Summary
Any user behind a corporate proxy is hard-bricked on the first SDK call.
```python
client_kwargs = {"verify": ..., "limits": limits} # no "headers"
if self.configuration.proxy:
client_kwargs["proxy"] = self.configuration.proxy
existing_headers = client_kwargs.pop("headers") # KeyError: 'headers'
```
client_kwargsis built literally above without a\"headers\"key, so thepopalways raises.Fix
client_kwargs.get(\"headers\") or {}as the base.proxy_headersto merge.httpxdoesn't have a dedicatedproxy_headerskwarg (that's a urllib3 API), so folding into default request headers is the closest equivalent — kept as a comment.openapi/templates/rest.mustacheso regen preserves the fix.Test plan
uv run pyright src/rapidata/rapidata_client→ 0 errorsHTTPS_PROXY=http://…run (don't have a proxy handy in this env).🔗 Session: https://session-bc38cc85.poseidon.rapidata.internal/