matrix-org / matrix-org/matrix-spec
Finer granularity error codes in order to support i18nized errors from the server
- Dominant language
- HTML
- Stars
- 330
- Forks
- 150
- Avg merge
- 2h 21m
- Merged PRs (30d)
- 3
Description
Right now there are many APIs where we return a generic 400,403,404 etc with a human readable error in English but no finer-granularity error code which a client could pick up and present a proper i18nized error message. Surely we need some kind of solution for this - whether it's either mandating servers do the i18n for errors themselves based on Accept language headers, or having much more sophisticated and finer granularity errors.
A good example is the groups API:
```
Matthews-MacBook-Pro:synapse matthew$ grep -ri 'group' . | fgrep \" | grep -i error | fgrep .py:
./groups/groups_server.py: raise SynapseError(400, "Group not on this server")
./groups/groups_server.py: raise SynapseError(404, "Unknown group")
./groups/groups_server.py: raise SynapseError(404, "Unknown group")
./groups/groups_server.py: raise SynapseError(403, "User is not admin in group")
./groups/groups_server.py: raise SynapseError(404, "Unknown group")
./groups/groups_server.py: raise SynapseError(403, "User not in group")
./groups/groups_server.py: raise SynapseError(403, "User not invited to group")
./groups/groups_server.py: raise SynapseError(403, "Group is not publicly joinable")
./groups/groups_server.py: raise SynapseError(403, "User is not admin in group")
./groups/groups_server.py: raise SynapseError(400, "Group already exists")
./groups/attestations.py: raise SynapseError(400, "Attestation has incorrect group_id")
./groups/attestations.py: raise SynapseError(400, "Neither user not group are on this server")
./storage/group_server.py: raise SynapseError(400, "room not in group")
./storage/group_server.py: raise SynapseError(400, "user not in group")
./federation/transport/server.py: raise SynapseError(403, "group_id doesn't match origin")
```
Where clients will not only want to i18nize but also s/group/communities/ for presentation to the user (see https://github.com/vector-im/riot-web/issues/6003).
Related: https://github.com/matrix-org/matrix-doc/issues/1638 and https://github.com/matrix-org/matrix-doc/issues/603
Contributor guide
Research direction
Start by reviewing the error cases in groups/groups_server.py, groups/attestations.py, storage/group_server.py, and federation/transport/server.py, then read the related matrix-doc issues 1638 and 603. Define the unresolved requirements for client-visible error codes and internationalized presentation; done would require an agreed, documented solution rather than changes to one named file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, internationalization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100