Repository navigation
Conversation
| serde_path_to_error::deserialize(jd).map_err(|e| { | ||
| HttpError::for_bad_request( | ||
| None, | ||
| format!("unable to parse JSON body: {}", e), |
There was a problem hiding this comment.
If we're going this far, I think "unable to parse JSON body" should be changed as well. IMO from the point of view of an API consumer, the fact that the error arises as a failure to parse is a bit of an implementation detail. From the API's point of view the point is that it's an invalid body, just as negative disk size would be invalid, even though it's technically parseable.
I'm not sure drawing a distinction between the two is useful to the API consumer, or least if it is, where we're drawing the line is not where I would draw it. As in: to me, I'd expect to get an error about unparseable JSON if what I sent was not JSON at all. The "unable to parse" error for something that's technically JSON but not what the API wanted is confusing.
There was a problem hiding this comment.
I see you point. What would you prefer to see here?
There was a problem hiding this comment.
“Invalid request body: …” seems ok. I think in the case where it’s not even JSON, you’ll get a reasonably suggestive message after that about “expected { at line 1”, right? It might still be helpful to say “could not parse JSON” in that case.
There was a problem hiding this comment.
It seems like if it's not JSON at all, you do want to mention that, right? It might not be obvious from whatever's expected ("expected ','") that the problem is it's not JSON at all.
for oxidecomputer/omicron#1848