Skip to content

ENG-4325: Guard nil rack.input for Rack 3 compatibility#3

Open
remmons wants to merge 1 commit into
masterfrom
ENG-4325/rack-3-compat
Open

ENG-4325: Guard nil rack.input for Rack 3 compatibility#3
remmons wants to merge 1 commit into
masterfrom
ENG-4325/rack-3-compat

Conversation

@remmons

@remmons remmons commented Jun 22, 2026

Copy link
Copy Markdown
Member

ENG-4325

Purpose

Make the gem compatible with Rack 3. Under Rack 3, env["rack.input"] is no longer guaranteed to be present — it is nil for bodyless requests (e.g. GET), whereas Rack 2 always supplied an empty StringIO. The doc generators call .rewind on it unconditionally, so every GET example raised NoMethodError: undefined method 'rewind' for nil and failed to document.

This blocks the Rack 2 → 3 upgrade in promote (ENG-4325) — all 13 */doc_spec.rb API-doc specs there fail without it.

Approach

Treat a nil rack.input as an empty body in both readers:

  • ClientBase#read_request_bodyreturn "" if input.nil? before rewind/read.
  • TestServer#call — guard the rewind/read of env["rack.input"] (same nil case).

No behavior change on Rack 2 (input is always present there); on Rack 3 a bodyless request now documents an empty body instead of crashing.

Testing

Verified against promote's Rack 3.1.21 branch with this fork pointed in via a local path: override: all 13 doc_spec.rb examples pass (were 13/13 failing with rewind for nil).

@remmons remmons requested a review from cfaloon June 22, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant