-
-
Notifications
You must be signed in to change notification settings - Fork 244
feat(mobile-app): Make missing path not panic #2583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,8 @@ pub fn make_command(command: Command) -> Command { | |
| .value_name("PATH") | ||
| .help("The path to the mobile app files to upload. Supported files include Apk, Aab or XCArchive.") | ||
| .num_args(1..) | ||
| .action(ArgAction::Append), | ||
| .action(ArgAction::Append) | ||
| .required(true), | ||
| ) | ||
| .arg( | ||
| Arg::new("sha") | ||
|
|
@@ -49,9 +50,13 @@ pub fn make_command(command: Command) -> Command { | |
| } | ||
|
|
||
| pub fn execute(matches: &ArgMatches) -> Result<()> { | ||
| 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(()); | ||
| } | ||
| }; | ||
|
|
||
| let sha = matches | ||
| .get_one("sha") | ||
|
|
@@ -301,14 +306,12 @@ fn upload_file( | |
| build_configuration.unwrap_or("unknown") | ||
| ); | ||
|
|
||
| let chunk_upload_options = api | ||
| .get_chunk_upload_options(org)? | ||
| .ok_or_else(|| { | ||
| anyhow!( | ||
| "The Sentry server lacks chunked uploading support, which \ | ||
| let chunk_upload_options = api.get_chunk_upload_options(org)?.ok_or_else(|| { | ||
| anyhow!( | ||
| "The Sentry server lacks chunked uploading support, which \ | ||
| is required for mobile app uploads. {SELF_HOSTED_ERROR_HINT}" | ||
| ) | ||
| })?; | ||
| ) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like an autoformat update. |
||
| })?; | ||
|
|
||
| if !chunk_upload_options.supports(ChunkUploadCapability::PreprodArtifacts) { | ||
| bail!( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/integration/_cases/mobile_app/mobile_app-upload-no-path.trycmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ``` | ||
| $ sentry-cli mobile-app upload | ||
| ? failed | ||
| error: the following required arguments were not provided: | ||
| <PATH>... | ||
|
|
||
| Usage: sentry-cli mobile-app upload <PATH>... | ||
|
|
||
| For more information, try '--help'. | ||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.