-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rack3 breaking change with query param nil #2298
Comments
I think this (requiring Rack 3.0+) is a breaking 2.0 change, and should probably release 1.7.1 before merging it. The other alternative is to support both, not do a major version increment, and have clearly separate specs for Rack 2.x and Rack 3.x and document the difference in behavior. This is a bit more involved, would potentially hide the behavior change of someone doing a WDYT? |
I don't personally have a strong opinion about this. Is this change semantically breaking something that was previously working? |
@ioquatix yes, I believe this is a semantically breaking change. Per above, passing a query params like |
I think it would be easier to it in two steps starting with upgrading rake-test and limit rack < 3. It would give more time to think about |
Are there any HTML controls which generate query strings like this e.g. that differentiate between |
I don't know but when looking at rack's tests, it's now |
What I'm asking is whether browsers actually utilise the difference. |
@ioquatix Most of users of Grape aren't browsers. We're an API framework. |
I see, so is there any difference between |
Rack3 foo=bar&baz => {"foo"=>"bar", "baz"=>""}
foo=bar => {"foo"=>"bar"} Rack2 foo=bar&baz => {"foo"=>"bar", "baz"=>nil}
foo=bar => {"foo"=>"bar"} The tricky part is this change only affect query parameters. A body payload would still have |
I understand that, but is there any difference, if I write |
Isn't the Rack 3 case of |
Yes, IIUC, that's the case. And it's done that way to match the RFCs. However, my question is, why specify baz at all if you just want it to be nil? |
Because I want to pass If I am not mistaken, with this change an |
That's a valid point. Should we keep the current behavior for Since Rails 5, testing an API in a Rails app will automatically use # will be application/x-www-form-urlencoded
post '/my_endpoint', params { my_params: 'test' }
# will be application/json
post '/my_endpoint', params { my_params: 'test' }, as: :json If we choose to have a different behavior, it might gives some headaches. |
I don't believe Rack parses JSON, or does it? We use our own parser. I expect no changes for JSON data, that would be a massive regression. |
I dont think it does, its just the way the request is built under the hood. Anyway, I believe we should have the same behavior no matter if it's |
Also, #2294 will definitely bring some changes on Rack 3.1. We might want to make a stable release for |
If we can find justification from an RFC to handle Alternatively, we could either:
|
@ericproulx Feel free to PR what you think is right, including making a release. I agree that locking Rack down < 3 because of known issues is the right thing to do now. @ioquatix I like the idea of extracting parsers out of Rack. Grape would like Rack not to parse data, really, and bring its own parser next to the JSON one or any other parser. I can see some issues with other Rack middleware and the assumptions being made that Rack always parses |
I went looking for specifications today and the closest thing I found was https://url.spec.whatwg.org/#application/x-www-form-urlencoded which states that:
So it seems to me there is no valid representation of "null". That being said, this is a retrospective specification, the full extent of the query part of a URL is left un(der) specified. |
The correct place to fix this (if anything can be done) is in the standard. I've made an issue and linked it. I suggest if you feel passionate about it, to go and comment on it. |
There is a vulnerability in rack < 2 that some security monitoring software is currently bugging me about: rack/rack#1732 |
@kbarrette I'd start by making a PR that has passing specs with Rack 3. We can consider a major version upgrade that only supports v3, but I would prefer not to. |
|
@kbarrette So now we pass specs with Rack 3. Should we close this? |
@dblock I don't know if fixing the tests addressed all of @ericproulx's concerns. As for me, I'd like to see a new version released so I can resolve my snyk alert. |
Add a +1 to #2349. I'll do a release this week if another maintainer doesn't beat me to it (please do!). |
@dblock this has been fixed in rack 3.0.7. Should we add some information in the readme to specify that if you're using rack 3.X you need at least to be >= 3.0.7 ? @ioquatix thanks for all the work. |
I would update/edit tests that were modified in #2346 in a way that fails with rack < 3.0.7 and passes with rack >= 3.0.7, and then just close this. If you think a note is helpful, why not. |
GH worflows always run the latest 3.* so its ain't an issue for testing. I'll leave it like this. |
While updating
rack-test
locally to the latest version,rack
got updated also to it's latest version 3.0.3Some tests are failing due to the following breaking change :
What does it means ? Passing a query params like
?name
will be considered by Rack (>=3) as{ "name" => "" }
instead{ "name" => nil }
.Moslty, it affects all the
optional
parameters that you can passparam_name: nil
.Question? Since it's a breaking change, should we update the gemspec to keep
rack
< 3. That's one breaking change, but there might be others since other specs are falling.Tests failing:
Othere tests failing with Rack > 3
The text was updated successfully, but these errors were encountered: