Avoid infinite recursion when there is a redirect #338
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.
After upgrading to Rails 4.2.0, I began receiving a
SystemStackError
when Rails boots. After quite a bit of debugging, I traced it to the fact that I am using theapi!
method in my controllers to auto-detect the route for a given description. After more debugging, I traced it to the fact that I have several "catchall" redirects in myroutes.rb
file.Apparently when the method
Apipie::Application#route_app_controller
attempts to recursively figure out the controller for a given app, the app generated fromredirect
satisfies none of the conditions and it will recurse until Ruby stops it.I'm not sure of the exact fix, someone with more domain knowledge will have to say whether my patch is right or not. I was able to cause the problem under Rails 4.2 by adding the redirect route; I was able to stop the problem by adding another check to the condition.
Let me know if there is something more I can do to help with this PR.