Skip to content

feat(mobile-app): Make missing path not panic#2583

Merged
rbro112 merged 6 commits intomasterfrom
ryan/make_missing_path_not_panic
Jul 10, 2025
Merged

feat(mobile-app): Make missing path not panic#2583
rbro112 merged 6 commits intomasterfrom
ryan/make_missing_path_not_panic

Conversation

@rbro112
Copy link
Copy Markdown
Member

@rbro112 rbro112 commented Jul 8, 2025

Updates the mobile-app upload command to no longer panic upon a missing path argument, rather log an error and exit gracefully. Adds a test to validate this behavior.

@rbro112 rbro112 requested a review from szokeasaurusrex as a code owner July 8, 2025 17:15
Copy link
Copy Markdown
Member Author

rbro112 commented Jul 8, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@rbro112 rbro112 changed the title Make missing path not panic feat(mobile-app): Make missing path not panic Jul 8, 2025
is required for mobile app uploads. {SELF_HOSTED_ERROR_HINT}"
)
})?;
)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like an autoformat update.

Comment on lines +54 to +56
None => {
eprintln!("path argument is required");
return Ok(());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should instead return an error so that we exit with nonzero status

Copy link
Copy Markdown
Member Author

@rbro112 rbro112 Jul 8, 2025

Choose a reason for hiding this comment

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

I took this impl from the proguard mapping upload, will update but notable that that command does not return an error.

let path_strings: Vec<_> = match matches.get_many::<String>("paths") {
Some(paths) => paths.collect(),
None => {
return Err(anyhow!("path argument is required"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry I did not realize this earlier in the review, but I believe there should be a way to get clap to enforce the path argument as required?

If you cannot get it to work, I'd try to write a better error message, as path is a positional argument, and as written, the error message could be confusing to users since there is no --path argument.

Something like "you must provide at least one path to upload" I think would be better

Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

See comment before merge, looks good otherwise!

Comment on lines -52 to +59
let path_strings = matches
.get_many::<String>("paths")
.expect("paths argument is required");
let path_strings: Vec<_> = match matches.get_many::<String>("paths") {
Some(paths) => paths.collect(),
None => {
// Clap will handle the case where no paths are provided.
return Ok(());
}
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since clap is handling this already (or at least, as it should be), I would go back to the expect (which panics) since getting into the state where we don't have paths at this point is unexpected and would indicate a bug in Sentry CLI. You can update the expect message to state that Clap is enforcing that the argument is required.

@rbro112 rbro112 merged commit d8ca95b into master Jul 10, 2025
26 checks passed
@rbro112 rbro112 deleted the ryan/make_missing_path_not_panic branch July 10, 2025 17:20
rbro112 added a commit that referenced this pull request Jul 10, 2025
…2588)

Since we have the clap arg required now from #2583, let's go back to the
original panic as this would definitely be a CLI bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants