Send correct message from civogo sdk when api key is invalid #212
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue link in cli repo
Description
When Civo users attempt to use the CLI with an incorrect API key, the error message displayed in the terminal is both unclear and exposes internal details, which is not user-friendly. This PR addresses that issue by providing a more meaningful and helpful error message.
This is more of a workaround PR.
Currently, Civo CLI relies on the civogo SDK, which communicates with the Civo backend. When an invalid API key is used, the backend responds with an error message like:
This message is then passed along and presented to the user as: (on terminal)
Changes in this PR and suggestions -
The error message database_account_not_found will now be translated to a more user-friendly message:
InvalidAPIKeyError: "API Key is invalid, please visit https://dashboard.civo.com/security to generate a new one"`
Suggestions:
While this specific message "database_account_not_found" for an invalid api key could have some historical context, it would be better if the backend error were more descriptive, such as using codes like
invalid_api_key
orwrong_api_key
to reflect the actual issue.For now, this PR focuses on improving the user-facing message to provide clarity and guidance on resolving the issue.
Let me know in case you guys want to change the incoming message from the backend, I will refactor and accommodate for those changes in subsequent PRs.
For now, we should be in a good shape to unblock the issue .