tailscale-client-go icon indicating copy to clipboard operation
tailscale-client-go copied to clipboard

Fixup runtime error in client.go

Open hosom opened this issue 1 year ago • 2 comments

Without a c.init() in the UseOAuth method, BaseURL must be specified, or this code will result in a SIGSEGV on client.go:121 (122 after this commit).

This is one possible way to fix this issue. Alternatively, implementing a NewClient would probably be reasonable too.

hosom avatar Sep 11 '24 19:09 hosom

@oxtoacart and @mpminardi are discussing this and considering options. The "v2" API design isn't quite nailed down yet and this might change.

Alternatively, implementing a NewClient would probably be reasonable too.

Personally, I like the style of exporting optional things and telling users to stop touching them after initialization. It makes more for a lot less ceremony than c, err := tailscale.NewClient(tailscale.ClientOpts{.....})) or the sea of zero values in tailscale.NewClient(foo, 0, nil, "", 0, nil)

bradfitz avatar Sep 11 '24 22:09 bradfitz

Thanks for calling this out @hosom ! This should be addressed as of https://github.com/tailscale/tailscale-client-go/pull/112 (with https://github.com/tailscale/tailscale-client-go/pull/115 containing a follow-up bugfix).

Our README for the v2 of the client has also been updated to show the new method of configuring OAuth.

mpminardi avatar Sep 20 '24 17:09 mpminardi

@hosom Thanks for bringing this to our attention and proposing a fix. I'm going to close this PR, but please let us know if you run into any lingering issues.

oxtoacart avatar Sep 25 '24 21:09 oxtoacart