Skip to content

Remove to_ary from Response#1453

Merged
ioquatix merged 1 commit intomasterfrom
rm_to_ary_from_response
Jan 7, 2020
Merged

Remove to_ary from Response#1453
ioquatix merged 1 commit intomasterfrom
rm_to_ary_from_response

Conversation

@tenderlove
Copy link
Copy Markdown
Member

Responses are not arrays, so we should not allow them to be implicitly
coerced to an array. If you would like you response to be converted to
an array, you must explicitly do it with the to_a method.

This also prevents creation of unnecessary body proxies

refs #419

Responses are not arrays, so we should not allow them to be implicitly
coerced to an array.  If you would like you response to be converted to
an array, you must explicitly do it with the `to_a` method.

This also prevents creation of unnecessary body proxies
@tenderlove tenderlove added this to the v2.1.0 milestone Jan 7, 2020
@tenderlove tenderlove requested review from ioquatix and jeremy January 7, 2020 05:25
@tenderlove
Copy link
Copy Markdown
Member Author

I was able to confirm that without removing this line the flatten tests I added would go in to an infinite loop.

@dblock
Copy link
Copy Markdown
Contributor

dblock commented Jan 7, 2020

Looks like this will break Grape, ruby-grape/grape#1955. I haven't dug deep here, @dnesteryuk can probably provide an explanation.

@delner
Copy link
Copy Markdown

delner commented Jan 10, 2020

It does indeed break Grape; middleware/base.rb doesn't coerce the response it gets to an Array which eventually causes Router#cascade? to receive an Array with [#<Rack::Response>, nil nil].

This issue explains the effect on Grape: ruby-grape/grape#1966

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.

6 participants