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
Check auth status #32
Comments
Fixes cli#32. Also exports error types.
@heaths This does seem like a useful feature to have. I took a quick look at #33 and it looks good so far, but I am going to hold off on a full review for now since I have immediate plans to add lots of functionality for working with |
Understood. #33 also had a couple options I was expecting to explore. Making the errors public, for example, would at least give callers a way to check for specific errors (apart from taking a fragile dependency on the error string) but if the new work could at least provide a consistent, clear message that the user might not be authenticated that would also be helpful. Then it's just a single error type we'd have to check to give a more actionable message - unless |
If the CLI isn't already authenticated, extensions can fail in various ways depending on what they call. For example, using
gh.CurrentRepository()
- even in a repo - fails witherrors.New("unable to determine current repository, none of the git remotes configured for this repository point to a known GitHub host")
. If you specify a repo explicitly,gh.GQLClient()
can fail with an internalconfig.NotFoundError
which, given it's ininternal
, cannot be referenced so might as well be a genericerror
. To the user, the error simply prints "not found" which isn't actionable. Even the more wordy error mentioned first isn't that actionable, though more useful.Instead, what about something like
gh.IsAuthenticated() bool
? It could, for example, callconfig.Load()
and then check theConfig.AuthToken
for a known host. This would allow extensions to easily check up front if they should prompt the user to authenticate.Alternatively, expose any auth-related errors in
pkg
or something so we can do type assertions.The text was updated successfully, but these errors were encountered: