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

PATCH /doc/{docId} return 200 even when inconsistent values are sent #1241

Open
1 of 2 tasks
hexaltation opened this issue Oct 3, 2024 · 0 comments
Open
1 of 2 tasks

Comments

@hexaltation
Copy link
Collaborator

hexaltation commented Oct 3, 2024

Describe the current behavior

Patching a document to change its type within API console we realized that values are not checked.
Supported DocTypes are "", "tutorial", "template" according to the code.

(

export type DocumentType = 'tutorial'|'template';
)
(
type: DocumentType|null;
)

However patching with type "nonsense" returns a 200 with a null response body.

curl -X 'PATCH' \
  'http://localhost:8484/api/docs/rmj1XMJ1CdPf84vdgWsMBu' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer XXXXXXXXXXX' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "nonsense"
}'

Steps to reproduce

  1. open console API
  2. select PATCH docs/{docId} route
  3. try to patch with
{
  "type": "someExoticType"
}
  1. have a 200 as response and type set to "SomeExoticType" when using GET docs/{docId}

Describe the expected behavior

The API must return a 400 Bad request or a 422 Unprocessable Entity when trying to patch with invalid data.

May be we can validate data against a schema for keys expecting well defined values.

Where have you encountered this bug?

Instance information (when self-hosting only)

No response

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