CSCfi / CSCfi/rems

Implement "Problem Details for HTTP APIs" RFC

Open
#2,402 0 comments 0 reactions 0 assignees View on GitHub
Technical Debt
Dominant language
Clojure
Stars
66
Forks
28
Avg merge
7d 4h
Merged PRs (30d)
2

Description

https://tools.ietf.org/html/rfc7807

Currently our HTTP error responses are inconsistent. In various situations we return
- a generic text like `forbidden`
- a specific text like `field id must not be empty`
- a JSON object like `{"error": "not found"}`
- a schema error like
```
{
"schema": "{:application-id Int}",
"errors": {
"application-id": "missing-required-key",
"application-i": "disallowed-key"
},
"type": "compojure.api.exception/request-validation",
"coercion": "schema",
"value": {
"application-i": 0
},
"in": [
"request",
"body-params"
]
}
```

In contrast, for HTTP 200 we have well-defined schemas and we represent command and validation errors uniformly:
```
{"success":false,"errors":[{"type":"t.actions.errors/disabled-catalogue-item","catalogue-item-id":123}]}
```

Some things to consider:
- What URLs do we want to send in the `type` field? Links to docs on Github? Serve the error descriptions from REMS itself?
- Should we localize `title` according to the requested language?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.