for-GET / http-decision-diagram

An activity diagram to describe the resolution of HTTP response status codes, given various headers.
https://github.com/for-GET/http-decision-diagram/blob/master/doc/2013-06-10-http-hell-no.md
Apache License 2.0
3.63k stars 196 forks source link

isn't it should be M2 to M3 instead of to M2 to N3? #57

Open septianw opened 4 years ago

septianw commented 4 years ago

How if i create with method POST and endpoint create (create_path) but has conflict or duplicate. isn't it should be M2 to M3 instead of to M2 to N3?

andreineculau commented 4 years ago

409 "indicates that the request could not be completed due to a conflict with the current state of the resource." as per https://tools.ietf.org/html/rfc7231#section-6.5.8

You are conflating "state of the resource" with state in general, i believe. In this case of the diagram, the request is meant to create a new resource, thus it cannot logically hit a 409 because there is no resource state to conflict with.

It may conflict with the general state e.g. POST /mygarage/cars -> 409 "garage is already full" but that can (should, by some API patterns) be a two-requests step: 1. Create the car (POST /cars -> 201 /cars/id123; will work no matter how full the garage is) 2. Add it to the garage (POST /mygarage add car id123 to my garage), and this time the request goes via the process section of the diagram and may return 409 "garage is already full". Did i lose you or do you understand the difference?

I must note though that all the 500 blocks in the diagram mean "anything goes, i cannot come up with a generic logical flow so you know better from here on", not "you must return 500". I think i mentioned that somewhere, if not - i should.

-- http://andreineculau.com

On 15 Jan 2020, at 22:15, Septian Wibisono notifications@github.com wrote:

 How if i create with method POST and endpoint create (create_path) but has conflict or duplicate. isn't it should be M2 to M3 instead of to M2 to N3?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

septianw commented 4 years ago

Understood. According to this diagram, how to prevent conflict when posting same content of field? e.g:

  1. Create car: POST /cars with value "corvette zr1" -> 201 /cars/id123
  2. Create car again with same value : POST /cars with value "corvette zr1" -> should be conflict, there's another record with same value.

I don't know whats inside, so i can't afford PUT.