Make server errors exported #295

Closed
opened 2025-12-29 01:26:19 +01:00 by adam · 5 comments
Owner

Originally created by @GrigoriyMikhalkin on GitHub (Jul 25, 2022).

There's a bunch of errors that headscale server can return. For example "Namespace already exists". Would it be desirable to export them?

Specifically i would find it useful as i use headscale as a lib to create a built-in client in a service. And there i want to check returned errors.

Originally created by @GrigoriyMikhalkin on GitHub (Jul 25, 2022). There's a bunch of errors that `headscale` server can return. For example [`"Namespace already exists"`](https://github.com/juanfont/headscale/blob/main/namespaces.go#L19). Would it be desirable to export them? Specifically i would find it useful as i use `headscale` as a lib to create a built-in client in a service. And there i want to check returned errors.
adam added the enhancement label 2025-12-29 01:26:19 +01:00
adam closed this issue 2025-12-29 01:26:19 +01:00
Author
Owner

@juanfont commented on GitHub (Jul 28, 2022):

@GrigoriyMikhalkin happy to merge a PR doing this :)

Btw, out of pure curiosity, what is the use case?

@juanfont commented on GitHub (Jul 28, 2022): @GrigoriyMikhalkin happy to merge a PR doing this :) Btw, out of pure curiosity, what is the use case?
Author
Owner

@GrigoriyMikhalkin commented on GitHub (Jul 28, 2022):

@juanfont
I'm trying to implement VPN connection for machines provided by metal-stack(which is MaaS platform basically). Headscale is deployed to serve as a control-plane. And then we have metal-api service, which is basically middleware that organizes deployment of bare metal machines. metal-api also should be able to manage VPNs and connect these machines to it. For that metal-api uses headscale as a lib to connect remotely to Headscale installation and manage namespaces/auth keys.

Regarding exporting errors. Here i'm trying to catch the Namespace already exists error.

It actually could be solved in another way(additional request to get all namespaces and try to find the one that's expected), but it just doesn't feel as an elegant solution.

I was thinking about using GetNamespace method, but it also returns an error which is not exported.

@GrigoriyMikhalkin commented on GitHub (Jul 28, 2022): @juanfont I'm trying to implement VPN connection for machines provided by [metal-stack](https://github.com/metal-stack/)(which is MaaS platform basically). Headscale is deployed to serve as a control-plane. And then we have `metal-api` service, which is basically middleware that organizes deployment of bare metal machines. `metal-api` also should be able to manage VPNs and connect these machines to it. For that `metal-api` uses `headscale` as a lib to connect remotely to Headscale installation and manage namespaces/auth keys. Regarding exporting errors. [Here](https://github.com/metal-stack/metal-api/pull/308/files#diff-e3be14987652bb48dcefbab95f677cfd5db025653af59c036ffdad1bb5d1f898R252) i'm trying to catch the `Namespace already exists` error. It actually could be solved in another way(additional request to get all namespaces and try to find the one that's expected), but it just doesn't feel as an elegant solution. I was thinking about using `GetNamespace` method, but it also returns an error which is not exported.
Author
Owner

@juanfont commented on GitHub (Jul 29, 2022):

Happy to get all the errors exported. Can you prepare a PR?

On Thu, 28 Jul 2022 at 23:46, GrigoriyMikhalkin @.***>
wrote:

@juanfont https://github.com/juanfont Here
https://github.com/metal-stack/metal-api/pull/308/files#diff-e3be14987652bb48dcefbab95f677cfd5db025653af59c036ffdad1bb5d1f898R252
i'm trying to catch the Namespace already exists error.

It actually could be solved in another way(additional request to get all
namespaces and try to find the one that's expected), but it just doesn't
feel as an elegant solution.

I was thinking about using GetNamespace method, but it also returns an
error which is not exported.


Reply to this email directly, view it on GitHub
https://github.com/juanfont/headscale/issues/690#issuecomment-1198664382,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABMGQZYEGONYLFD7BEVZUTVWL5UFANCNFSM54TYVXYQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

@juanfont commented on GitHub (Jul 29, 2022): Happy to get all the errors exported. Can you prepare a PR? On Thu, 28 Jul 2022 at 23:46, GrigoriyMikhalkin ***@***.***> wrote: > @juanfont <https://github.com/juanfont> Here > <https://github.com/metal-stack/metal-api/pull/308/files#diff-e3be14987652bb48dcefbab95f677cfd5db025653af59c036ffdad1bb5d1f898R252> > i'm trying to catch the Namespace already exists error. > > It actually could be solved in another way(additional request to get all > namespaces and try to find the one that's expected), but it just doesn't > feel as an elegant solution. > > I was thinking about using GetNamespace method, but it also returns an > error which is not exported. > > — > Reply to this email directly, view it on GitHub > <https://github.com/juanfont/headscale/issues/690#issuecomment-1198664382>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AABMGQZYEGONYLFD7BEVZUTVWL5UFANCNFSM54TYVXYQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@GrigoriyMikhalkin commented on GitHub (Jul 29, 2022):

@juanfont Yep, sure!

@GrigoriyMikhalkin commented on GitHub (Jul 29, 2022): @juanfont Yep, sure!
Author
Owner

@juanfont commented on GitHub (Aug 11, 2022):

Fixed :)

@juanfont commented on GitHub (Aug 11, 2022): Fixed :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#295