mobility-data-specification icon indicating copy to clipboard operation
mobility-data-specification copied to clipboard

Error and bulk responses

Open johnzuk opened this issue 1 year ago • 6 comments

I want to clarify bulk responses error http codes.

Let's assume i want process multiple vehicles through agency/vehicles endpoint - lets say 3 of them. Lets say first vehicle is already registered, second one has wrong type in filed device_id and third one is correct. What should be api response and http code in that case? Should it be 409 or 400 or 201 and response like:

{
  "success": 1,
  "total": 3,
  "failures": [
  ... //all details here abut failures  
  ]
}

johnzuk avatar Dec 05 '23 21:12 johnzuk

Going to tag @jiffyclub on this for a quick reply. Thanks!

schnuerle avatar Dec 13 '23 22:12 schnuerle

I personally think I would reject the whole batch if there was a failure and return an error code relevant to the first error I found. I would stop processing the batch at the first error and return that one.

jiffyclub avatar Feb 02 '24 21:02 jiffyclub

Yes I agree with @jiffyclub. Stop at the first error and return that one. Is that standard behavior, or is a note needed in the spec to make this more clear?

schnuerle avatar Apr 11 '24 14:04 schnuerle

Let's decide on the behavior and wording change to the spec, and we can add this in 2.1.

schnuerle avatar May 30 '24 20:05 schnuerle

Probably worth a note so we don't get too many wildly divergent implementations, but the most important part is setting an HTTP error code so the client knows something went wrong and look into it. As long as there's an error and the error message is useful the client can investigate.

jiffyclub avatar Jun 06 '24 16:06 jiffyclub