GRPC response codes not explicitly set for all errors #547

Closed
opened 2025-12-29 02:19:51 +01:00 by adam · 2 comments
Owner

Originally created by @IvoGoman on GitHub (Sep 1, 2023).

Why

The CreateUser GRPC endpoint for returns Code: 2, Message: "User already exists" if the user already exists.
The error code 2 refers to an unknown error (see statuscodes ) However, in this situation the error code 6 for Already Exists would make error handling on the client side more convenient.

Description

In some error cases there are custom errors used (e.g. users ) which can be mapped to one of the official GRPC error codes.
In those cases I would like the GRPC API to return the error with the correct/official status code such as it is done in some places: e3acc95859/hscontrol/grpcv1.go (L117)

Originally created by @IvoGoman on GitHub (Sep 1, 2023). ## Why The CreateUser GRPC endpoint for returns `Code: 2, Message: "User already exists"` if the user already exists. The error code 2 refers to an unknown error (see [statuscodes](https://grpc.github.io/grpc/core/md_doc_statuscodes.html) ) However, in this situation the error code 6 for Already Exists would make error handling on the client side more convenient. ## Description In some error cases there are custom errors used (e.g. [users](https://github.com/juanfont/headscale/blob/e3acc958598ca968a41c4d5dfe91826f1d1a1cff/hscontrol/db/users.go#L13-L14) ) which can be mapped to one of the official GRPC error codes. In those cases I would like the GRPC API to return the error with the correct/official status code such as it is done in some places: https://github.com/juanfont/headscale/blob/e3acc958598ca968a41c4d5dfe91826f1d1a1cff/hscontrol/grpcv1.go#L117
adam added the enhancementstale labels 2025-12-29 02:19:51 +01:00
adam closed this issue 2025-12-29 02:19:51 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 11, 2023):

This issue is stale because it has been open for 90 days with no activity.

@github-actions[bot] commented on GitHub (Dec 11, 2023): This issue is stale because it has been open for 90 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (Dec 19, 2023):

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions[bot] commented on GitHub (Dec 19, 2023): This issue was closed because it has been inactive for 14 days since being marked as stale.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#547