matrix-org / matrix-org/matrix-spec
Validation errors in error responses (SPEC-405)
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 330
- Forks
- 150
- Avg merge
- 2h 21m
- Merged PRs (30d)
- 3
Description
It would be very useful if error responses included a Rails-style errors object with details of why a request was rejected on a per-field basis. Right now, when you submit a request with a large and complicated structure and an error is returned, it can be very difficult to figure out why it was rejected, since all you have to go on is an error code and a single, general message.
I'm imagining something like this:
``` javascript
{
"errcode": "M_BAD_JSON",
"error": "The request failed validation.",
"errors": {
"base": [
"You cannot supply both the foo and the bar key at the same time."
],
"fields": {
"foo": [
"cannot be blank"
],
"bar": [
"must be a positive integer"
]
}
}
}
```
The `errors` key-value pair itself would be optional for backwards compatibility and if there would be nothing valuable to put there for a given request, but if present, it would contain both base and field-level validation error messages, either of which could be empty if they don't apply.
(Imported from https://matrix.org/jira/browse/SPEC-405)
(Reported by Jimmy Cuadra)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Matrix specification sections that define error responses and validation failures. Compare existing response schemas with the proposed optional errors object, including base and field-level messages and backward compatibility. Done means the specification resolves the schema and scope for per-field validation details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- api, documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100