openmobilityfoundation / mobility-data-specification

A data standard to enable right-of-way regulation and two-way communication between mobility companies and local governments.
https://www.openmobilityfoundation.org/about-mds/
Other
676 stars 232 forks source link

Error and bulk responses #891

Open johnzuk opened 7 months ago

johnzuk commented 7 months ago

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  
  ]
}
schnuerle commented 6 months ago

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

jiffyclub commented 5 months ago

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.

schnuerle commented 2 months ago

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 commented 1 month ago

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

jiffyclub commented 3 weeks ago

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.