From 7160d52f0c26961a792e449da4cd25b13e7d40c0 Mon Sep 17 00:00:00 2001 From: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:34:16 +0200 Subject: [PATCH] fix(crons): Don't panic when passing `--auth-token` (#2172) 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 --- 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...");