Skip to content

Commit 7160d52

Browse files
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
1 parent df403cd commit 7160d52

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/commands/monitors/run.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use sentry::protocol::{MonitorCheckIn, MonitorCheckInStatus, MonitorConfig, Moni
1111

1212
use crate::api::envelopes_api::EnvelopesApi;
1313
use crate::utils::system::QuietExit;
14+
use crate::utils::value_parsers::auth_token_parser;
1415

1516
pub fn make_command(command: Command) -> Command {
1617
command
@@ -96,7 +97,12 @@ pub fn make_command(command: Command) -> Command {
9697
),
9798
)
9899
// Hide auth token from --help output
99-
.arg(Arg::new("auth_token").long("auth-token").hide(true))
100+
.arg(
101+
Arg::new("auth_token")
102+
.long("auth-token")
103+
.value_parser(auth_token_parser)
104+
.hide(true),
105+
)
100106
}
101107

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

142148
let envelopes_api = EnvelopesApi::try_new()?;
143-
149+
144150
if let Err(e) = envelopes_api.send_envelope(open_checkin) {
145151
log::error!("Failed to send in-progress check-in envelope: {e}");
146152
log::info!("Continuing to run program...");

0 commit comments

Comments
 (0)