Skip to content
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

provide a better error when the user is not logged in #1772

Closed
dovholuknf opened this issue Feb 25, 2024 · 3 comments · Fixed by #1969
Closed

provide a better error when the user is not logged in #1772

dovholuknf opened this issue Feb 25, 2024 · 3 comments · Fixed by #1969
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@dovholuknf
Copy link
Member

Running ziti edge list ers (or anything really) does not provide a CLEAR error to the user indicating they just aren't logged in. The feedback should be much more obvious than what is currently output.

See:

$ ziti edge list ers
error: no identity 'default' found in cli config /home/cd/.config/ziti/ziti-cli.json

☝️ not exactly obvious that they just haven't logged in yet...

@dovholuknf dovholuknf added enhancement New feature or request good first issue Good for newcomers labels Feb 25, 2024
@Vrashabh-Sontakke
Copy link
Contributor

I would like to work on this issue.
The codebase is quite big, please help me find files related to this issue!

@plorenz
Copy link
Member

plorenz commented Apr 15, 2024

I would like to work on this issue. The codebase is quite big, please help me find files related to this issue!

That errors comes from here: https://github.com/openziti/ziti/blob/v1.0.0/ziti/util/identities.go#L328

A basic fix would maybe check the identity count and return an error saying you need to login if there are 0 saved logins. Above and beyond that, if the selected saved login isn't found you could output the list of saved logins and let the user know they could either login or use ziti edge use to select an existing saved login.

@Vrashabh-Sontakke
Copy link
Contributor

Thank you so much @plorenz for the jumpstart.

Vrashabh-Sontakke added a commit to Vrashabh-Sontakke/ziti that referenced this issue Apr 23, 2024
This commit enhances the `LoadSelectedIdentity` function in the [identities.go](https://github.com/openziti/ziti/blob/a60ed6ffb6d539664151584ccd01b1740fc4d2b2/ziti/util/identities.go#L241C1-L255C2) file by adding improved error handling and checks for the existence of identities in the CLI configuration.

Previously, the function only threw an ambiguous error if the selected identity was not found in the CLI config. 
However, with this enhancement, the function now checks if there are any saved identities in the CLI config. 
If no identities are found, it returns an error instructing the user to log in using the `ziti edge login` command.
Additionally, if the specified identity is not found, it returns an error message indicating that the identity could not be found in the CLI config and provides instructions on how to select an existing identity using `ziti edge use <identity_name>`.

These changes improve the robustness of the function by ensuring that appropriate error messages are provided in scenarios where the user is not logged in or when the selected identity is missing.

fixes openziti#1772 thanks to @plorenz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants