-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
HTML dumps in console some times when testing API endpoints. #25226
Comments
@prathamesh-sonpatki I tried your config setting. It sort of worked...
I think the correct behavior is for Rails to give an error message with exception/traces in JSON response for API endpoints and a normal HTML response for HTML endpoints. Without knowing the internals of Rails, I think if some thing inherits from ActionController::API then use the JSON response and if it inherits from ActionController::Base then use the HTML response... just an idea but you guys know Rails internals way way better than me. Looking at the API trace response, I see web-console middleware exists in the API stack. It would be nice if its bypassed or even better eliminated since you'll never use web-console in an API endpoint, but have it present for the HTML endpoint. This is an ideal nicety in reducing unnecessary overhead, but definitely not a showstopper. 😃 |
@hmistry For Rails 4.x the default behavior was to always show HTML responses for even JSON requests too. With API apps, this got changed to JSON when But it got fixed in c33bda8. So on master, if you use Regarding web console, for API only apps web-console gem is not present in the Gemfile. But I think you have normal app, so you are getting it in the stack traces. Not sure how to include it based on request type. Also it might be surprising behavior for some cases. |
We shouldn't be even trying to show the console in the JSON responses, if we detect such, so this shouldn't be a problem IMO. You'll get the console only for HTML error responses, where we can properly show it and it may be useful for you to diagnose the problem. If we do show it in a JSON response, then please report it as a bug to rails/web-console and we'll look into it. |
@prathamesh-sonpatki I'm unable to verify your patch because I'm having trouble updating rails to that commit or Let me know if you have any ideas in how I can get around the gem compatibility issues, let me know, otherwise I'll have to wait to 5.0.0.rc2 release to verify it. |
@prathamesh-sonpatki Let's re-open this issue since you verified yesterday that the fix in |
Assigning to myself. Just a clarification, this is not a blocker for 5.0 release. |
Any update for a fix on this issue? |
This issue has been automatically marked as stale because it has not been commented on for at least three months. |
I'm filing this issue to bring to your attention in case no one else has... it might have been addressed but I couldn't find any in a quick search.
Steps to reproduce
I will update with more specific steps when I encounter it again. Sorry.
I'm using Rails 5rc1 to develop a mixed web and API rails app. Some times when things go wrong, I get html responses (some times there's even references to
web-console
) during testing the API only endpoints in development.Have an API endpoint that returns
json
normally. Send a invalid request using curl in the console, and you'll receive a rails error html dump to your console.Updated with steps:
Use curl in a console to visit an invalid route and you'll see the HTML error page response in your console.
Expected behavior
I expect a plain text message with the error that is better formatted for the console.
Actual behavior
HTML web page dump response to console.
System configuration
Rails version: 5.0.0.rc1
Ruby version: 2.3.0
The text was updated successfully, but these errors were encountered: