-
-
Notifications
You must be signed in to change notification settings - Fork 235
feat: Improve upload error message to show cause #2765
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
feat: Improve upload error message to show cause #2765
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
// 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 | ||
}; |
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.
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.
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.
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>
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.
Looks good! But, before merging, please update the PR/squashed commit title, as this change is no longer specifically improving VCS provider error messages, but is more generally improving the error messages for all file processing errors.
## 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>
Summary
--vcs-provider
parameter valuesBefore this PR:
After this PR:
Closes EME-301
🤖 Generated with Claude Code