Ruby Status 302 - Dont know what that means? - ruby-on-rails

When i run the xxx.rb using localhost:3000/xxx I initially - before adding the require-client gem got two input boxes for name and email. that was just a basic template where you can do the usual edit/update/delete etc. However once i write the require 'rest_client' and update the gem this is what i get. Im not even sure if this is an error or if its just a way of saying rest_client was found. If so how do i go to my applicaiton to get the two boxes or get the application back up and running. i have a few more code to write to get this functionality working. however is this an intermediate state or an error ?
RestClient::Found in xxxController#index
302 Found
Rails.root: /Users/user1/Desktop/rails_projects/xxx_app
Application Trace | Framework Trace | Full Trace
app/models/xxx.rb:8
app/controllers/xxx_controller.rb:1
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None

This is not an error. You should look into Location header as described here: http://restpatterns.org/HTTP_Status_Codes/302_-_Found
Generally 2xx are OK good repsonses, 3xx are intermittent ones, could lead to good or bad later, 4xx are expected errors (like page not found) and 5xx are fatal server errors
I have some basic RESTful API responses outlined here (not a complete list) http://vova.org/2011/06/24/restful-http-response-codes/

Related

Potentially dangerous Request.Path due to doubled url

I'm maintaining a legacy .NET 4.7.2 MVC application that uses Umbraco CMS 7.15.7. We started getting failed requests registered in Azure Application Insights with the following message
A potentially dangerous Request.Path value was detected from the client (:).
I've seen that it is related to requests such as these (below is a sample request that usually occurs in Application Insights logs, I've just changed the real website domain):
timestamp [UTC]
2021-09-28T21:50:31.1808953Z
name
GET /companies/ https:/www.sample-site.com/companies/sample-company
url
https://www.sample-site.com/companies/ https:/www.sample-site.com/companies/sample-company
success
False
resultCode
400
duration
0.1136
performanceBucket
<250ms
itemType
request
customDimensions
{"_MS.ProcessedByMetricExtractors":"(Name:'Requests', Ver:'1.1')"}
operation_Name
GET /companies/ https:/www.sample-site.com/companies/sample-company
client_Type
PC
client_IP
0.0.0.0
sdkVersion
web:2.9.0-23612
I realise that the problem (:) is because the url and the name end up being somehow "doubled" (https://www.sample-site.com/companies/ https:/www.sample-site.com/companies/sample-company). My goal is not to allow such requests, but rather find the cause of them.
Here are my conclusions as to what might be causing this issue:
The failed requests seem to occur periodically, and in bulk - every 5-10 hours. One product page never gets called twice within a bulk. This led me to believe that they might be caused by a bot, but then again the pattern isn't always clear - there will be minutes apart between two requests.
The requests seem to occur mostly for product pages that are under a certain node in Umbraco (in this instance, the companies node). However, there are some product pages under that node in Umbraco that don't have the occurrence.
The failed request contains https:/ with only one "/", which is odd and seems that this part is concatenated at some point
The few successful requests under the companies node always have a 301 status code, which leads me to believe that the issue could be related to a broken redirect rule somewhere
The error started occurring after we changed some content in Umbraco for certain product pages (mostly canonicalUrl properties of product page nodes). But then again, there are some product pages that do have the property filled out, but do not get the issue.
I can never relate these requests to a user or session in Application Insights
I am aware that this might be too specific to debug and that this might be caused by practically anything - but I do have a feeling that it's somehow related to Umbraco, so somebody with experience in Umbraco and the knowledge how the name property could end up being generated as GET /companies/ https:/www.sample-site.com/companies/sample-company could lead me to some clues?
As additional information, here is a successfully executed request to a product page under the same node in Umbraco:
timestamp [UTC]
2021-09-29T07:27:54.2739984Z
name
GET /companies/second-company
url
https://www.sample-site.com/companies/second-company
success
True
resultCode
301
duration
6.4651000000000005
performanceBucket
<250ms
itemType
request
customDimensions
{"_MS.ProcessedByMetricExtractors":"(Name:'Requests', Ver:'1.1')"}
operation_Name
GET /companies/second-company
client_Type
PC
client_IP
0.0.0.0
sdkVersion
web:2.9.0-23612
Can you add ValidateRequest=false at the top of your page.
Also,
As you are using .Net 4.7.2 you need to allow the below urls in web.config file.
<system.web>
<httpRuntime
requestPathInvalidCharacters="<,*,>,%,&,\,?" />
</system.web>
I have removed the (:), the original default string is
<httpRuntime
requestPathInvalidCharacters="<,>,*,%,&,:,\,?" />
Check these SO1 and SO2 with related discussions.
After doing some research, I found the cause of the issue, so I believe it could be beneficial to others if I share it even though quite some time passed: the requests with incorrect URL were sent by an external SEO tool which we used - so the error originated outside of the system. These requests were sent by the SEO tool as they are shown here, e.g. https://www.sample-site.com/companies/ https:/www.sample-site.com/companies/sample-company, so they weren't malformed somewhere in the request pipeline of our system.

SAPUI5 invalid MIME part type with Remote oDATA Service

I need help showing the data from my own remote server with oDATA.
When I want to show the data in the view, I get the following error
invalid MIME part type.
These are the Captures of Error
my https://******/$metadata?
My Table control from SApui5 Course App example
Error when executing the application
And Console error
When I insert this.getModel().setUseBatch(false) in the init : function () of the Component.js, it does not give me the error, nor in the console, but it does not show me the records either .. Can someone give me an idea?
It's an old question, but recently I've got the same error with batch request processing and in my case the root cause was that when building batch processing response with content type multipart/mixed you have to use CRLF as a text line separator ('\r\n') and not only '\n'. See also here in multipart response specification. The hard part was that correct and incorrect responses look absolutely identical when debugging.

Null exception after calling Post Request

I am building a web api on asp.net. I make requests through client and server. GET and DELETE methods are working properly. When i make POST or PUT i get an error "Response status code does not indicate success: 500 (Internal Server Error)."
Client:
Server:
I used this tutorial.
Why i get a null object (Employee)?
If AddEmployee is an endpoint, then you may need to put the [FromBody] attribute on the parameter.
If it's not an endpoint, then I don't see where AddEmployee is being called. But it looks like the employee parameter is the one that is null. Look up the stack trace, and I bet you'll find someplace where employee is not being set.
I dont know how but when i built a new project the error dissapeared... I used the exact same files and classes.

Rails error handling

Stack: Ruby 2.2, Rails 4.2, and Honeybadger.
I've been working on the error handling code for my site. I've noticed that error handling has become a real mess though out the site, and I've been looking for a way to standardize error handling.
The following "generic" error types have been found:
Record/resource not found
Failure to save record
Validation issues
Rights/Permissions errors
Other (Usually probing bots, double clicks, or WTF?)
With the following resulting actions.
Notify Error Collating resource (maybe)
Save data; if a particularly long form input
Response: Redirect to an error page (flash[:error]='?')
Response: Return a JSON string (AJAX requests)
Response: Various Status codes http 3xx, 4xx, 5xx
Customized message for developer (maybe); quite lengthy in some cases
Customized message for user
Silently do nothing
And then process issues
Roll back
return (exiting the action; and not allowing further action)
Does anyone know of a Gem/Module/Tutorial that handles these collective issues holistically?
Thank you in advance!
-daniel
I think the best answer, is to throw an exception
Controller code is responsible for getting the parameters, sanitizing them, role/safety checks, making calls to GET data (this should be business logic), and the preparing the data for export back to the browser.
I'll add on to this handling exceptions from the code.
Then business logic, should throw an error should something fatalistic happen.

I got 'Document is empty' when using grape

all
I got the error when using grape.
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
in fact, My api works and return the xml well. and after sometime's running , it start to buggy. show that error. my server is nginx + passenger. rails2.3.8. + grape. any help?
The error is from Chrome, displayed when content-type is xml and the xml is not well formed, or in your case as the error indicates, empty. Your api will still work from clients (such as curl) that do not parse and verify the content type.
It's best to hit your api with curl instead of a browser when you encounter something odd.

Resources