Describe return codes for account data endpoints + minor clarifications#1155
Describe return codes for account data endpoints + minor clarifications#1155richvdh merged 15 commits intomatrix-org:mainfrom DMRobertson:dmr/account-data
Conversation
turt2live
left a comment
There was a problem hiding this comment.
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. |
| type: object | ||
| 400: | ||
| description: |- | ||
| The request body is not a JSON object. Errcode: `M_BAD_JSON`. |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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