Skip to content

Commit

Permalink
fix(crons): Don't panic when passing --auth-token (#2172)
Browse files Browse the repository at this point in the history
The --auth-token argument is hidden from the sentry-cli monitors run subcommand since the command uses DSN authentication, however passing the argument is still possible (it is simply ignored).

However, providing this argument causes a panic with a not-very-user-friendly message, since the argument was defined here without the auth token parser, and we attempt to read the auth token as an AuthToken.

This PR fixes the bug.

Fixes #2170
  • Loading branch information
szokeasaurusrex authored Oct 22, 2024
1 parent df403cd commit 7160d52
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/commands/monitors/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use sentry::protocol::{MonitorCheckIn, MonitorCheckInStatus, MonitorConfig, Moni

use crate::api::envelopes_api::EnvelopesApi;
use crate::utils::system::QuietExit;
use crate::utils::value_parsers::auth_token_parser;

pub fn make_command(command: Command) -> Command {
command
Expand Down Expand Up @@ -96,7 +97,12 @@ pub fn make_command(command: Command) -> Command {
),
)
// Hide auth token from --help output
.arg(Arg::new("auth_token").long("auth-token").hide(true))
.arg(
Arg::new("auth_token")
.long("auth-token")
.value_parser(auth_token_parser)
.hide(true),
)
}

fn run_program(args: Vec<&String>, monitor_slug: &str) -> (bool, Option<i32>, Duration) {
Expand Down Expand Up @@ -140,7 +146,7 @@ fn execute_checkin(
};

let envelopes_api = EnvelopesApi::try_new()?;

if let Err(e) = envelopes_api.send_envelope(open_checkin) {
log::error!("Failed to send in-progress check-in envelope: {e}");
log::info!("Continuing to run program...");
Expand Down

0 comments on commit 7160d52

Please sign in to comment.