Fallback to StringIO to prevent nil.rewind errors #3
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Before Rack 3.1,
last_request.env["rack.input"]
was an empty StringIO object when there wasn't a rack input.As of Rack 3.1
last_request.env["rack.input"]
isnil
when there is no input.This is a stumbling block for rspec_api_documentation's inner functionings.
Solution, short term edition
As a "for now" solution, we can fall back in to StringIO when generating docs. This PR makes StringIO.new the default when
last_request.env["rack.input"]
isnil
.A good thing about this solution is that it will address the rspec doc generation problem without forcing a pin on rack. We do not want to pin rack because it is involved in production functionality and we want to be sure to keep up to date in order to capitalize on all security and performance updates.
In contrast, our posture towards rspec_api_documentation is weaker because there has not been an official release since 2018 and the library is not in the path of production requests.
Solution, longer term edition (not in this PR)
One of these: