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

Return a more helpful error message when an invalid API key is used #312

Open
richardlewisjones opened this issue Apr 24, 2023 · 6 comments
Assignees

Comments

@richardlewisjones
Copy link

When an invalid API key is used, users see this error message:

Please check if you are using the latest version of CLI and retry the command 
If you are still facing issues, please report it on our community slack or open a GitHub issue (https://github.com/civo/cli/issues) 
Error: DatabaseAccountNotFoundError: Failed to find the account within the internal database

The error message does not mention the API key, and a reference to 'the internal database' is not helpful. A better message would be something like API key is invalid. See https://www.civo.com/api#authentication

@richardlewisjones richardlewisjones changed the title Return a more helpful error message when an invalid API keys is used Return a more helpful error message when an invalid API key is used Apr 24, 2023
@dipu989
Copy link
Contributor

dipu989 commented Sep 21, 2024

Hey @alejandrojnm Do you think issue is still a valid one?
If yes, I can raise a PR to fix this.
I also think that internal db error messages should not be exposed to clients, let me know what do you think?

@alejandrojnm
Copy link
Member

Hi thanks for asking, I'm not sure we can ask to @uzaxirr about this

@dipu989
Copy link
Contributor

dipu989 commented Sep 21, 2024

Sure thing!
@uzaxirr Let us know your thoughts on this?

@uzaxirr
Copy link
Member

uzaxirr commented Sep 23, 2024

hey @dipu989
on the latest version of CLI, if you use a wrong API key you will get.
Screenshot 2024-09-24 at 12 48 22 AM

the API will return the below response

{
    "code": "database_account_not_found",
    "reason": "Failed to find the account within the internal database"
}

Please let me know your approach and raise a PR

@dipu989
Copy link
Contributor

dipu989 commented Sep 23, 2024

@uzaxirr How about error like - WrongAPIKeyError: API Key is invalid.

I am not sure if WrongAPIKeyError will be a valid error type in the code base but probably we can add this type of Error in the enum? What do you think?
This actually gives the user, a proper reason for failure without exposing any internal implementation detail.

Forbidden or Permission Denied doesn't make a lot of sense here, as this ain't a typical API response 🤔
Let me know if you think otherwise.
Thanks.

@uzaxirr
Copy link
Member

uzaxirr commented Sep 23, 2024

@dipu989 please raise a PR

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

No branches or pull requests

5 participants