Skip to content

Mark "Remove to_ary from Response` as breaking#1675

Merged
ioquatix merged 1 commit intorack:masterfrom
srpouyet:patch-1
Jun 29, 2020
Merged

Mark "Remove to_ary from Response` as breaking#1675
ioquatix merged 1 commit intorack:masterfrom
srpouyet:patch-1

Conversation

@srpouyet
Copy link
Copy Markdown
Contributor

@srpouyet srpouyet commented Jun 26, 2020

Response to_ary was removed in commit 72959eb.

This is a breaking change if the response is used for multiple assignment of variables.

Example that worked with < 2.1.0:

status, headers, body = response

With version 2.1.0 the value of headers changes from a hash to nil.
To prevent this the response must be explicitly cast to an array with to_a as noted in the commit message of the change.

We had an issue with a custom rack app whose call method returned Rack::Response.new(json). This worked fine in version 2.0.2, but caused a NoMethodError in action_dispatch/journey/router.rb.

We think it's a good idea to mark this change as breaking in the changelog, so people will be able to check their code before upgrading, what do you think?

Response `to_ary` was removed in commit 72959eb.

This is a breaking change if the response is used for multiple assignment.

Example (works for < 2.1.0):
```
status, headers, body = response
```
The value of `headers` will be `nil` in version > 2.1.0.
To prevent this the response must be explicitly cast to an array with `to_a`.
@ioquatix
Copy link
Copy Markdown
Member

I feel like this ship has already sailed but I'm okay to merge. @tenderlove ?

@tenderlove
Copy link
Copy Markdown
Member

I'm fine to merge this too

@ioquatix ioquatix merged commit c29e0f7 into rack:master Jun 29, 2020
@srpouyet
Copy link
Copy Markdown
Contributor Author

Cheers! Maybe this'll save someone who comes comes across this issue some time 👍

Also, thank you guys for your OSS-efforts. Much appreciated!

ch1c0t added a commit to ch1c0t/hobby that referenced this pull request Mar 26, 2021
@ch1c0t
Copy link
Copy Markdown
Contributor

ch1c0t commented Mar 26, 2021

Thank you. This notice was very helpful.

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.

4 participants