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

fix(api): Fix panic that occurred when sentry-cli login called with --auth-token #1893

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

szokeasaurusrex
Copy link
Member

@szokeasaurusrex szokeasaurusrex commented Jan 8, 2024

This PR fixes the bug in #1885 that led us to revert that commit. The bug, reported in #1888, caused the CLI to panic when the sentry-cli login command was called with the --auth-token argument.

We determined that the CLI panicked because the auth_token was being downcast to a String instead of to an AuthToken type when being read from the matches within the login command. This PR corrects the login command, so that the auth_token is correctly obtained from the matches as an AuthToken. We also checked whether the auth_token argument was being read as a String anywhere else in the code, and found that the login command was the only place the argument was being read as a String. Therefore, we would expect this PR to fix this class of bug completely.

Fixes GH-1859
Fixes GH-1888

Perform client-side validation of all Auth Tokens input to the Sentry CLI. To ensure future-compatibility, we only provide soft validation, meaning that we only print a warning message if we detect that the Auth Token is invalid – the CLI will still proceed with normal execution if the Auth Token is invalid.

Fixes GH-1859
@@ -31,7 +32,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
"{}/orgredirect/organizations/:orgslug/settings/auth-tokens/",
config.get_base_url()?
);
let predefined_token = matches.get_one::<String>("auth_token");
let predefined_token = matches.get_one::<AuthToken>("auth_token");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change that fixes the error – the other changes to this file in this commit are to handle the new type

@szokeasaurusrex szokeasaurusrex merged commit 8be89c6 into master Jan 8, 2024
12 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/auth-token-login-error branch January 8, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants