-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Describe return codes for account data endpoints + minor clarifications #1155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally this lgtm, though the errors need to reference the error schema and ideally have examples set for clarity/rendering in the spec.
This should be done now. Error messages are cribbed from Synapse. f58ea57 scope-creeps this a little by suggesting that bad room ids should also be rejected with a 400 status code. (Synapse doesn't do this yet, but I'm about to PR a change making that so.) This caused me to notice #1157. |
@@ -71,6 +71,38 @@ paths: | |||
application/json: {} | |||
schema: | |||
type: object | |||
400: | |||
description: |- | |||
The request body is not a JSON object. Errcode: `M_BAD_JSON`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum. https://spec.matrix.org/v1.3/client-server-api/#common-error-codes says we should use M_NOT_JSON
in this case. If synapse is using M_BAD_JSON
, I'd say that's a synapse bug. (And yes, those are terrible names for the error codes. Don't blame me.)
(similarly for PUT /user/{userId}/rooms/{roomId}/account_data/{type}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll fixup both.
When the spec speaks of "valid JSON", I guess it really means "a valid JSON object" as opposed to e.g. a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Judging from https://github.com/matrix-org/synapse/blob/33abbc327813e65aaa91e10f98a31622c045004c/synapse/http/servlet.py#L671-L694 it looks like Synapse is being naughty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, now I'm not sure if this change is correct. Synapse hits that code when it's parsed a JSON value that isn't an object (so list, bool, null, number or string). They're arguably all "valid JSON", just not the form of JSON that we were expecting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right, yes, I'd expect M_BAD_JSON
for a list where we expect an object. Which means that this endpoint can return either M_BAD_JSON
or M_NOT_JSON
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See b66b199
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
See individual commits.
Closes #1153.
https://pr1155--matrix-spec-previews.netlify.app/client-server-api/#client-config
Preview: https://pr1155--matrix-spec-previews.netlify.app