Skip to content

Make env['rack.input'] optional.#2018

Merged
ioquatix merged 1 commit intorack:mainfrom
socketry:optional-input
Jan 20, 2023
Merged

Make env['rack.input'] optional.#2018
ioquatix merged 1 commit intorack:mainfrom
socketry:optional-input

Conversation

@ioquatix
Copy link
Copy Markdown
Member

@ioquatix ioquatix commented Jan 19, 2023

Also introduce Rack::Multipart::MissingInputError for improved handling of missing input in #parse_multipart.

Fixes #1994. Fixes #1995.

@ioquatix ioquatix force-pushed the optional-input branch 2 times, most recently from ec67f1b to 9c4360c Compare January 19, 2023 01:48
@ioquatix
Copy link
Copy Markdown
Member Author

Ignore the failures in 2.5, it's done this before and seems an issue with rubygems/bundler/ruby-setup AFAICT.

Copy link
Copy Markdown
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

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

This will be OK once the the Ruby 2.4/2.5 CI removal is no longer included. I fixed the CI tests for Ruby 2.5 in #2021.

@jeremyevans
Copy link
Copy Markdown
Contributor

@ioquatix Can you remove the first commit and then rebase on master? Then this should be good to merge.

@ioquatix
Copy link
Copy Markdown
Member Author

Okay done.

@ioquatix ioquatix enabled auto-merge (squash) January 19, 2023 23:57
@ioquatix ioquatix requested a review from jeremyevans January 20, 2023 00:04
@ioquatix ioquatix disabled auto-merge January 20, 2023 00:30
@ioquatix ioquatix enabled auto-merge (squash) January 20, 2023 00:30
@ioquatix ioquatix merged commit 54368a0 into rack:main Jan 20, 2023
@ioquatix ioquatix deleted the optional-input branch January 20, 2023 00:54
delfinag added a commit to envato/jwt_signed_request that referenced this pull request Jun 21, 2024
This version of `rack` makes the request body optional. Omitting to
explicitly set `rack.input` on GET's will cause the request's header
verification to fail with:
```
NoMethodError:
  undefined method `read' for nil:NilClass
```
because there is no `request.body` to read the JWT token from.

See rack/rack#2018.
h-lame added a commit to meetcleo/apipie-rails that referenced this pull request Jul 5, 2024
Ever since rack/rack#2018 `rack.input` has been
optional so we can't assume it's there and call `read` or `rewind` on it in
`Apipie::Extractor::Recorder`. Using safe navigation to call these methods
seems like the simplest approach because we want to look for
`rack.request.form_hash` instead in both the situation where `rack.input` is
missing, or it's empty.
h-lame added a commit to meetcleo/apipie-rails that referenced this pull request Jul 5, 2024
Ever since rack/rack#2018 `rack.input` has been
optional so we can't assume it's there and call `read` or `rewind` on it in
`Apipie::Extractor::Recorder`. Using safe navigation to call these methods
seems like the simplest approach because we want to look for
`rack.request.form_hash` instead in both the situation where `rack.input` is
missing, or it's empty.
mathieujobin pushed a commit to Apipie/apipie-rails that referenced this pull request Jul 9, 2024
#939)

* Update how we use Rack::Utils to get status codes

As part of rack/rack#2137 (released in Rack 3) Rack
changed the values of `Rack::Utils::SYMBOL_TO_STATUS_CODE` so asking for
`:unprocessable_entity` now returns `nil`. The guidance has always been to use
`Rack::Util.status_code` (present in the API since Rack 1.1) so let's just do
that.

* Handle a missing `rack.input` in the env

Ever since rack/rack#2018 `rack.input` has been
optional so we can't assume it's there and call `read` or `rewind` on it in
`Apipie::Extractor::Recorder`. Using safe navigation to call these methods
seems like the simplest approach because we want to look for
`rack.request.form_hash` instead in both the situation where `rack.input` is
missing, or it's empty.

* Add rubocop-rspec_rails and get rubocop run to green

In rubocop/rubocop-rspec#1848 rubocop-rspec extracted
some cops to separate gems, and because we referenced one of them in our
rubocop_todo.yml the whole rubocop process wouldn't run because it doesn't like
config for cops it doesn't know about. We introducing the missing gem,
`rubocop-rspec_rails`, and fix the name in the config to let us run rubocop
again.

There is one infraction that exists in the source so we fix that to get us to a
green rubocop run.

* Only add rubocop-rspec_rails for ruby >-= 2.7

It's only available for 2.7+ and we still run this build on 2.6.
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.

Make env['rack.input'] optional if no entity body is given. should not process form data if it is a GET method

2 participants