feat: Improve upload error message to show cause#2765
Merged
runningcode merged 4 commits intomasterfrom Sep 19, 2025
Merged
Conversation
When the backend returns "Unsupported provider" error for invalid --vcs-provider parameter, show a user-friendly error message instead of the generic API error. Closes EME-301 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
src/commands/build/upload.rs
Outdated
Comment on lines
+312
to
+326
| // Check if this is the "Unsupported provider" error and provide a better message | ||
| let error_message = if let Some(source) = e.source() { | ||
| let source_str = source.to_string(); | ||
| if source_str.contains("Unsupported provider") { | ||
| if let Some(provider) = vcs_info.vcs_provider { | ||
| anyhow!("The VCS provider '{}' is not supported. Please check the --vcs-provider parameter.", provider) | ||
| } else { | ||
| anyhow!("The VCS provider is not supported. Please check the --vcs-provider parameter.") | ||
| } | ||
| } else { | ||
| e | ||
| } | ||
| } else { | ||
| e | ||
| }; |
Member
There was a problem hiding this comment.
A few thoughts:
- This deep nesting makes it difficult to understand what the code is doing. It should be possible to rewrite as a single if/else or match statement by chaining methods (like map) onto the option (you may even be able to solve it only with method chaining, no if/else/match needed)
- Rather than making a new error with anyhow, we should call .with_context on the original error, so the original error is preserved. The context should be the main error message
- Also, where is the "Unsupported provider" message coming from? Is it getting returned by the server? The current implementation just checking that the error string contains this message seems a bit brittle to me, as it would break if the server changes the error message, or if another error includes this string. If the only indicator of this error is this message, however, I guess it is ok to check directly against it. Still, rather than just doing a simple string contains operation, we should downcast the error to the appropriate type and check the field where the message would be set.
Contributor
Author
There was a problem hiding this comment.
This is a good point. I’ve updated the PR to pass the message directly from the server to the client. That should address 1 and 2.
Regarding 3: the error message is coming from the server here. getsentry/sentry@8a21a5a
Remove complex string matching logic and display error source directly. This shows the actual server error message (e.g., "Unsupported provider: xyz") instead of generic wrapper messages like "API request failed". 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Display file path on first line, then show Error and Cause on indented lines for better readability and clearer error context. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Thank you! Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
szokeasaurusrex
approved these changes
Sep 19, 2025
runningcode
added a commit
that referenced
this pull request
Sep 19, 2025
## Summary - Improves error handling for invalid `--vcs-provider` parameter values - When backend returns “400 Unsupported provider" error, shows user-friendly message instead of generic API error Before this PR: ``` WARN 2025-09-18 07:49:04.315821 +02:00 EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release. > Preparing for upload completed in 0.114s WARN 2025-09-18 07:49:05.135782 +02:00 Failed to upload 1 file: WARN 2025-09-18 07:49:05.135865 +02:00 - /Users/nelsonosacky/workspace/hackernews/android/app/build/outputs/apk/debug/app-debug.apk (API request failed) error: Failed to upload any files ``` After this PR: ``` WARN 2025-09-18 09:40:30.389061 +02:00 EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release. > Preparing for upload completed in 1.233s WARN 2025-09-18 09:40:32.341187 +02:00 Failed to upload 1 file: WARN 2025-09-18 09:40:32.342033 +02:00 - /Users/nelsonosacky/workspace/hackernews/android/app/build/outputs/apk/debug/app-debug.apk WARN 2025-09-18 09:40:32.342108 +02:00 Error: API request failed WARN 2025-09-18 09:40:32.342144 +02:00 Cause: sentry reported an error: Unsupported provider (http status: 400) error: Failed to upload any files ``` Closes EME-301 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
--vcs-providerparameter valuesBefore this PR:
After this PR:
Closes EME-301
🤖 Generated with Claude Code