Skip to content

fix: friendlier error for unauthenticated user#62

Closed
gianarb wants to merge 1 commit into
mainfrom
fix/clarify-err-message-for-unauthorized-user
Closed

fix: friendlier error for unauthenticated user#62
gianarb wants to merge 1 commit into
mainfrom
fix/clarify-err-message-for-unauthorized-user

Conversation

@gianarb

@gianarb gianarb commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

When a user is not logged, and never logged in the error message is not
that actionable. It says the user thy should login but now how to do it.

As reported by @ecv we can do a lot better.

There is another error that looks similar but exposes the right command
to run to login. This commit uses the same approach.

This is the current one in main

panic: failed to get token source: no active user set. Please login first

goroutine 1 [running]:
go.datum.net/datumctl/internal/cmd.RootCmd()
        /home/gianarb/git/datum/datumctl/internal/cmd/root.go:38 +0xc3a
main.main()
        /home/gianarb/git/datum/datumctl/main.go:15 +0x32
exit status 2

Here what user will get with this commit:

panic: failed to get token source: no active user set. Please login first using 'datumctl auth login'

goroutine 1 [running]:
go.datum.net/datumctl/internal/cmd.RootCmd()
        /home/gianarb/git/datum/datumctl/internal/cmd/root.go:38 +0xc3a
main.main()
        /home/gianarb/git/datum/datumctl/main.go:15 +0x32
exit status 2

NOTE: There is another race condition related to when we run
authentication and it prevents the help command to get printed to the
user. But I am working at it in another PR

Related #54

@gianarb
gianarb requested a review from ecv January 16, 2026 13:20
@scotwells

Copy link
Copy Markdown
Contributor

Could we make this error message more friendly and remove some of the technical details like failed to get token source: no active user set?

Here's what I'm thinking:

You haven't authenticated with Datum Cloud yet. Please login first using 'datumctl auth login' and retry the command.

Maybe if the user kicks on verbose mode using -v we can dump them more raw details for debugging.

@gianarb
gianarb force-pushed the fix/clarify-err-message-for-unauthorized-user branch from 37c7d31 to a7cae01 Compare January 19, 2026 13:11
@gianarb
gianarb requested a review from scotwells January 19, 2026 13:11
@gianarb

gianarb commented Jan 19, 2026

Copy link
Copy Markdown
Collaborator Author

Maybe if the user kicks on verbose mode using -v we can dump them more raw details for debugging.

I changed the error message for now. I would like to keep error handling/logging to its own PR because my plan is to go over all the commands that are not imported straight from kubectl to use the kube logger.

When a user is not logged, and never logged in the error message is not
that actionable. It says the user thy should login but now how to do it.

As reported by @ecv we can do a lot better.

There is another error that looks similar but exposes the right command
to run to login. This commit uses the same approach.

This is the current one in main
```
panic: failed to get token source: no active user set. Please login first

goroutine 1 [running]:
go.datum.net/datumctl/internal/cmd.RootCmd()
        /home/gianarb/git/datum/datumctl/internal/cmd/root.go:38 +0xc3a
main.main()
        /home/gianarb/git/datum/datumctl/main.go:15 +0x32
exit status 2
```

Here what user will get with this commit:

```
panic: failed to get token source: no active user set. Please login first using 'datumctl auth login'

goroutine 1 [running]:
go.datum.net/datumctl/internal/cmd.RootCmd()
        /home/gianarb/git/datum/datumctl/internal/cmd/root.go:38 +0xc3a
main.main()
        /home/gianarb/git/datum/datumctl/main.go:15 +0x32
exit status 2
```

NOTE: There is another race condition related to when we run
authentication and it prevents the `help` command to get printed to the
user. But I am working at it in another PR
@gianarb
gianarb force-pushed the fix/clarify-err-message-for-unauthorized-user branch from a7cae01 to bb05c83 Compare January 19, 2026 13:13
@gianarb
gianarb enabled auto-merge January 19, 2026 16:39
@gianarb

gianarb commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator Author

@gianarb gianarb closed this Jan 20, 2026
auto-merge was automatically disabled January 20, 2026 15:27

Pull request was closed

@scotwells
scotwells deleted the fix/clarify-err-message-for-unauthorized-user branch April 30, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants