Capturing an Exception before default error pages are rendered [duplicate] - ruby-on-rails

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Rails 3 Sending errors to email
I want to add custom code that sends the Admin an email each time there is a system failure and the default error files 404 and 500 are rendered.

Please have a look at exception_notifier gem – it is capable of sending emails with exception details to the address you configure.
As for 404 errors – it might a bit tricky to catch, you have to setup a wildcard route for that. In addition to that, sending emails on every 404 might be a bad option (these happen quite a few times for live sites).

Related

How to send post request with content-type:application/x-www-form-urlencoded with Karate? [duplicate]

This question already has an answer here:
Karate DSL: Getting connection timeout error
(1 answer)
Closed 2 years ago.
I have an endpoint that I use to get a token. I use content type as application/x-www-form-urlencoded. In body, I select "x-www-form-urlencoded" and provide 4 key values as seen in the picture. It works on postman, but I could not make it work in karate framework. I get connect time out error all the time. I tried to use form field for each key and one form field including all keys and values, but none of them worked. By the way, I did remove request section in the picture and try without request as well. it did not work, too.
Am I missing something? Thanks already and thanks for such a great tool for us!
Quite likely you have a corporate proxy in the picture. Do a search for other answers on SO, for e.g: https://stackoverflow.com/search?q=%5Bkarate%5D+postman+proxy
Here's how to set a proxy: https://github.com/intuit/karate#configure
karate.configure('proxy','http://myhost:80');
EDIT: for others landing here, besides the fact that an HTTP proxy may be in the picture - another place where Karate behaves a bit differently than Postman is that Karate does not auto-send an Accept header by default.

Internal Server Error being returned from ASP.NET MVC Action in Azure App Service Plan [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm hosting an ASP.NET MVC 4.6.2 application in Microsoft Azure in an App Service Plan and using it purely as an API (that is, I'm not using WebAPI but using standard Controllers and Actions as my API for a web UI that lives in a different project).
Everything was working fine until I started getting a generic 500 Internal Server Error returned from one of my Actions (also, all actions are configured to return JSON). Other Actions work fine.
I have Rollbar setup to log all Application exceptions and nothing was being reported.
What was causing this error?
A big clue was Rollbar exceptions being logged, therefore it was happening earlier in the pipeline before my application code was being executed.
I used the Postman extension for Chrome to test submitting to the API and it worked fine.
Thinking for a moment I concluded and confirmed that the AJAX request data being POSTed from the UI didn't conform to the method signature of the Action I was submitting to. In fact, it was a login form and I had incorrectly configured my front-end code to pass a text 'rememeber-me' to my boolean 'RememberMe' parameter instead of a true/false value. Fixing this fixed the issue.
What I need to investigate now is how to effectively produce details logs and alerts on this type of exception in production.

Is this dangerous to my Rails App?

We are hosted on Heroku, and have the NewRelic add on. Every day I check the errors, and almost every day this error comes up.
Action and Type
Middleware/Rack/Rack::MethodOverride#call
EOFError
Message
bad content body
This is a Rails Application, and so I figure it's not doing anything in particular other than returning a 440 response status because there is nothing at the url they are trying to access.
URL
/wp-admin/admin-ajax.php
Through some google-fu I found an article pertaining to this being a brute force attack on wordpress sites.
My specific question is:
Do I worry about this?
I inherited the site and am not sure if this is just something that happens, and if it is something that rails applications don't have to worry about? It seems fairly targeted towards wordpress, but I can't find any documentation on whether I should be doing more to stop this.
Other frequently pinged urls that don't exist on my application
/sites/all/libraries/elfinder/php/connector.minimal.php
/license.php
/tiny_mce/plugins/tinybrowser/upload_file.php
Any enlightenment on the subject would be great. Stack trace available if needed. Thanks in advance, overflowers.
As long as you don't have a route configured to handle those requests you then only have to worry about getting spammed these requests and losing network resources. They'll recieve a 404 Not Found error when they try to reach it and so there is nothing they can really do except slow your site if they spam requests. If they do it often you can ban their IP address.

Why are browsers unable to send http requests, other than GET and POST, natively? [duplicate]

This question already has answers here:
Are the PUT, DELETE, HEAD, etc methods available in most web browsers?
(7 answers)
HTTP PATCH support in browsers
(1 answer)
Closed 7 years ago.
Basically, the title says it all. I've encountered this issue while reading about http requests in rails tutorial:
The other two verbs, PATCH and DELETE, are designed for updating and
destroying things on the remote server. These requests are less common
than GET and POST since browsers are incapable of sending them
natively, but some web frameworks (including Ruby on Rails) have
clever ways of making it seem like browsers are issuing such requests.
Why is there a need to hack around to issue, for example, a PATCH request? Why aren't browsers able to natively perform such kind of things? Am I missing something?
I've been searching around for quite a while, but couldn't come up with a clear answer to these questions. Thank you in advance.

Between the URL being entered and parsed by Rails the final slash is being replaced with a comma

I'm working on a Rails application that works with data via the Shopify API, however it has just started giving me 500 errors when certain resources are requested via a proxy (as set in the app settings in Shopify).
The request is along the lines of:
/app/my-application/customers/1234.json
however the error log on Heroku is showing a GET request to:
/app/my-application/cusotmers,1234.json
I'm using the Shopify/shopify_api gem which was recently updated, otherwise nothing else in the config/routes has changed since this error began occurring.
Any help or pointers greatly appreciated!
I'll happily provide more information if anything relevant is missing above.
This was a bug in Shopify's service to proxy requests to applications.
I have just deployed a fix for the issue. I take full responsibility for the issue, and will try to improve our tests to avoid similar issues in the future.

Resources