Skip to content
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

Finer granularity error codes in order to support i18nized errors from the server #377

Open
ara4n opened this issue Sep 12, 2018 · 3 comments
Labels
A-Client-Server Issues affecting the CS API feature Suggestion for a significant extension which needs considerable consideration

Comments

@ara4n
Copy link
Member

ara4n commented Sep 12, 2018

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 element-hq/element-web#6003).

Related: https://github.com/matrix-org/matrix-doc/issues/1638 and https://github.com/matrix-org/matrix-doc/issues/603

@turt2live
Copy link
Member

More granular error codes are spread out over quite a few issues in the repo ftr.

@turt2live turt2live added feature Suggestion for a significant extension which needs considerable consideration A-Client-Server Issues affecting the CS API labels Sep 12, 2018
@KitsuneRal
Copy link
Member

You already started doing it with M_ errors - please just do it across the board. Just adding l10n to the server is unlikely to be much beneficial as there's more than one homeserver implementation anyway; I'd say that it's a good work for client SDKs.

@richvdh richvdh transferred this issue from matrix-org/matrix-spec-proposals Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Client-Server Issues affecting the CS API feature Suggestion for a significant extension which needs considerable consideration
Projects
None yet
Development

No branches or pull requests

3 participants