Repository navigation
feat: add opt-in retry for RemoteProtocolError and case-insensitive header merging - #40
Merged
Merged
Conversation
Generated by Fern CLI Version: unknown Generators: - fernapi/fern-python-sdk: 5.41.4
… case-insensitive header merging Improve HTTP client robustness with two behavioral changes: `RemoteProtocolError` no longer retries automatically (it now raises immediately unless the caller opts in via `retry_remote_protocol_errors`), and header merging is now case-insensitive so duplicate headers with different casing are deduplicated correctly. Key changes: - Add `retry_remote_protocol_errors: bool` to `RequestOptions`; `RemoteProtocolError` now raises by default instead of retrying, since the server may have already applied the request — callers must explicitly opt in to retry this error class - Add `_merge_headers()` helper that deduplicates headers case-insensitively, preventing duplicate headers (e.g. `PLAID-SECRET` + `plaid-secret`) from being sent together - Add `_AUTH_HEADERS` frozenset (`x-api-key`) so API key headers are redacted alongside `Authorization` in debug/log output - Add `_reject_dot_segment()` guard in `encode_path_param` / `quote_path_param` to reject `.` and `..` path parameter values that would silently rewrite the request URL - Add `_drop_extras_colliding_with_fields()` in `pydantic_utilities` to drop extra keys that collide case-insensitively with declared fields, preventing case-insensitive decoders (e.g. Go's `encoding/json`) from reading the wrong value 🌿 Generated with Fern
Kizy625
approved these changes
Oct 27, 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.
4.0.0 → 4.1.0
Added
RequestOptions.retry_remote_protocol_errors— new optionalboolfield that opts a request into retrying onhttpx.RemoteProtocolError(server disconnect / incomplete response); defaults toFalseand is bounded bymax_retries.Changed
RemoteProtocolErrorretry behavior — the HTTP client no longer retrieshttpx.RemoteProtocolErrorautomatically; it now raises immediately unlessretry_remote_protocol_errors: Trueis set inRequestOptions, since the server may have already applied the request.PLAID-SECRETandplaid-secret) are now deduplicated case-insensitively, with the last value winning; this prevents sending two headers where only one was intended.x-api-keyheader redaction — thex-api-keyheader is now redacted alongsideAuthorizationin any debug or log output produced by the HTTP client.encode_path_param()andquote_path_param()now raiseValueErrorwhen a value is.or.., preventing silent URL path rewriting by HTTP clients.See full changelog