Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimistic locking with ETags #37

Open
pvdbosch opened this issue Jan 6, 2020 · 1 comment
Open

optimistic locking with ETags #37

pvdbosch opened this issue Jan 6, 2020 · 1 comment
Milestone

Comments

@pvdbosch
Copy link
Contributor

pvdbosch commented Jan 6, 2020

In GitLab by @pvdbosch on Nov 14, 2019, 12:11

When creating or updating resources it may be necessary to expose conflicts and to prevent the 'lost update' or 'initially created' problem. Following RFC 9110 section "HTTP: Conditional Requests" this can be best accomplished by supporting the ETag header together with the If-Match or If-None-Match conditional header.

See https://opensource.zalando.com/restful-api-guidelines/#182

Optimistic locking for update/create scenarios with If(-None)-Match headers and status code 412 isn't well documented currently in our guidelines. Instead 409 is listed for updates with a failed optimistic locking, but this is in conflict with the RFC.
Only the use of these HTTP headers for caching purposes with GET is currently documented.

When we agree to use 412, we could introduce a specific problem type for failure by optimistic locking (412 Precondition failed might be used in other circumstances and be too vague).

Another section talks about some corner cases (e.g. when using embedding), though I that might be a bit overkill for the styleguide:
https://opensource.zalando.com/restful-api-guidelines/#optimistic-locking

@pvdbosch
Copy link
Contributor Author

pvdbosch commented Jun 15, 2022

we can also document 428 - Precondition required https://httpstatus.in/428/ if If-Match header is missing, but this may be more difficult to implement : if OpenAPI document mandates the header, it's difficult the return an different error than for other cases of an invalid request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant