Open HarelM opened 5 years ago
Looking at the code I think there should be an Error
header in the response with the details - that is the standard way that our API reports errors.
Thanks for the quick response!
I'll check it shortly, but shouldn't I get back a HTTP 400
error and not a HTTP 500
?
There are a range of error codes you might get depending on the error.
The error message I'm getting back in the body is:
ActiveRecord::RecordNotSaved: Failed to replace tags because one or more of the new records could not be saved.
The same error appears in the Error
header in the response.
Which is a bit generic - there's no mention of the fact that empty tag is invalid - which is what I would expect as a return error, and I would expect 400 status code since the data I'm sending is invalid, as far as I understand.
When my server returns 500 I know there's a problem in my server's code, but maybe this is just me...
Feel free to close this issue if returning 500 is a valid case for you.
Well the 500 is a callback - if there is no defined mapping for a given exception then it uses that.
I'm not saying it couldn't do better, but I doubt anybody is going to be rushing to fix it.
Easiest would be to raise some error message, if the tag content is empty:
trace.rb/update_from_xml_node
self.tags = pt.find("tag").collect do |tag|
raise OSM::APIBadXMLError.new("trace", pt, "Tag value may not be empty") if tag.content.empty?
Tracetag.new(:tag => tag.content)
end
When sending a request with a tag that is empty the server responses with a 500 error. I know this is not a valid request, but an error that explains what I sent wrong would help. Here's the invalid request body: