Skip to content

Preserve false request bodies for JSON encoding - #1691

Merged
iMacTia merged 4 commits into
lostisland:mainfrom
OskarEichler:codex/preserve-false-request-bodies
Oct 25, 2026
Merged

iMacTia merged 4 commits into
lostisland:mainfrom
OskarEichler:codex/preserve-false-request-bodies

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary

Preserve false bodies so JSON middleware can encode them.

Reproduction and verification

With request :json and the test adapter echoing env.body, post('/', false) produces an empty string before the fix and 'false' afterward. Verified POST/PUT/PATCH, true/zero/hash/array/string bodies and block overrides.

  • Individual patch: 21 focused Faraday checks passed (body); all 639 existing RSpec examples pass; changed-file RuboCop and Ruby syntax pass.
  • Combined installed-release-based branch: 639 existing examples, 1,124 focused checks, full RuboCop (75 files), YARD checks and gem packaging pass.
  • External faraday-net_http adapter suite: 386 existing examples, zero failures with the combined fixes.
  • Ruby 4.0.6 through rbenv. No production or live external HTTP operations.

Limitations

No test/spec files were added or changed because the originating repository explicitly forbids this. Reproductions ran outside the repository. This differs from Faraday's requested regression-test contribution convention and is disclosed for maintainer review. Other Ruby versions/platforms were not run locally. This PR includes only the focused source change; the other fixes and the consumer's separately verified merged JSON decoder patch #1687 are not added here.

Breaking-change notes

False now reaches middleware instead of being silently discarded. Nil behavior is unchanged.

@iMacTia iMacTia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked with a JSON validator and false is indeed a valid JSON body, so this change makes sense. I just want to add a small test case to make sure this and other literals are correctly covered and tested

@iMacTia

iMacTia commented Oct 25, 2026

Copy link
Copy Markdown
Member

Tests added in #1728, the PR CI is currently failing exactly on the false scenario, as expected.

This PR fixes that 👍

@iMacTia
iMacTia merged commit 2d923f3 into lostisland:main Oct 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants