Repository navigation
fix: keep Response API when omitting request data - #1736
Merged
olleolleolle merged 1 commit intoNov 13, 2026
Merged
Conversation
Sanitizing flagged Responses as Hashes broke middleware calling on_complete, including retry flows. Build a fresh Response from response fields alone so request data stays hidden without losing that API. Prefer explicit response bodies for nil-status Responses while retaining the legacy body fallback. Keep RaiseError's existing Hash responses unchanged.
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.
Purpose
Keep
Faraday::Error#responsecompatible withFaraday::Responseconsumers when request data is omitted, including callers that use#on_complete.Background
#1729 broadened
include_request: falseto errors raised by other middleware but represented sanitized responses as Hashes. This causesNoMethodErrorwhen middleware expects a Response; return a fresh Response whose Env copies only status, response headers, and response body. Request fields, custom members, and the original Response backlink are not retained, so the request-data protection from #1729 remains intact.Out of Scope
The Hash response values generated directly by
RaiseErrorfor 4xx/5xx responses remain unchanged. Pre-existing issues involving wrapped JSON parser messages and late-finished Responses are also unchanged.Operational Notes
For finished Responses,
#bodynow prefers the explicit response body when present, including for nil-status responses and false bodies. The legacyEnv#bodyfallback remains for statusless middleware that does not populateresponse_body.