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

Unallowed State Transition Response Codes #53

Closed
GioAc96 opened this issue Mar 20, 2023 · 2 comments
Closed

Unallowed State Transition Response Codes #53

GioAc96 opened this issue Mar 20, 2023 · 2 comments
Labels
breaking For changes that might break service behavior enhancement New feature or request

Comments

@GioAc96
Copy link

GioAc96 commented Mar 20, 2023

Description

When requesting an unallowed state transition on a document on the CRUD service (ie: from PUBLIC to DELETED) the CRUD service responds with a 404 NOT FOUND status code and the following response body:

{
    "error": "not found"
}

However, I find this response not helpful, as it is the same that is returned when the document is not found. I believe that the appropriate response would be a 400 BAD REQUEST with a response body similar to something like this:

{
  "error": "transitions from state 'PUBLIC' to 'DELETED' are not allowed"
}

Environment

I'm using CRUD Service version 4.0.0, but I suspect that this issue is also relevant for newer versions

Minimal Reproduction

  • Create a document with __STATE__ set to PUBLIC
  • Request a state change by performing a POST request to /your-collection/your-document-id/state with the request body set to:
{"stateTo":"DELETED"}
  • Observe the returned response status code
@GioAc96 GioAc96 added the bug Something isn't working label Mar 20, 2023
@danibix95 danibix95 added enhancement New feature or request breaking For changes that might break service behavior and removed bug Something isn't working labels Mar 22, 2023
@danibix95
Copy link
Collaborator

I would not consider this a bug, but rather an enhancement of the interface. We can work on it to improve CRUD Service interface, but let's keep in mind that it will be a breaking change, since CRUD Service users may have built a logic considering the current HTTP response.

@danibix95
Copy link
Collaborator

#122 closes this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking For changes that might break service behavior enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants