From 7c9e2048dc7274057fd5f7b0c5eb4c8c92278725 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Mon, 30 Sep 2024 15:13:07 +0200 Subject: [PATCH] fix(crons): Don't panic when passing `--auth-token` 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, previously providing this argument caused 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 --- src/commands/monitors/run.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/commands/monitors/run.rs b/src/commands/monitors/run.rs index db69aad663..3eac575617 100644 --- a/src/commands/monitors/run.rs +++ b/src/commands/monitors/run.rs @@ -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 @@ -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, Duration) { @@ -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...");