Improve CLI error reporting on abp.io auth/license failure#25443
Merged
Conversation
- RemoteServiceExceptionHandler: catch all non-cancellation exceptions during error response deserialization (was only catching Newtonsoft JsonReaderException, but the active serializer throws System.Text.Json JsonException, leaking '<' is an invalid start of a value to users) - AbpIoSourceCodeStore: wrap 401/403 responses from abp.io endpoints in CliUsageException with login + license hint, so users get an actionable message instead of HTML-as-JSON parse failure - Add unit tests for RemoteServiceExceptionHandler covering HTML body, valid JSON error, 5xx, and OperationCanceledException propagation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves ABP CLI diagnostics when abp.io returns non-JSON error pages (notably 401/403 HTML responses during template/source downloads), so users get actionable guidance instead of JSON parse errors.
Changes:
- Broadened
RemoteServiceExceptionHandlerJSON-deserialization error handling to tolerateSystem.Text.Jsonexceptions (and other non-cancellation failures) and fall back to generic HTTP status messaging. - Added abp.io–specific response handling in
AbpIoSourceCodeStoreto throw aCliUsageExceptionwith guidance on login/license checks for 401/403 responses. - Added unit tests covering HTML body handling, valid JSON error bodies, 5xx behavior, and
OperationCanceledExceptionpropagation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectBuilding/RemoteServiceExceptionHandler_Tests.cs | Adds unit tests validating improved error handling and cancellation propagation. |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/RemoteServiceExceptionHandler.cs | Makes remote error parsing resilient to non-Newtonsoft JSON exceptions and non-cancellation failures. |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs | Introduces a shared helper to convert 401/403 abp.io responses into actionable CLI usage errors. |
- Drop manual HttpResponseMessage dispose in DownloadSourceCodeContentAsync, consistent with Volo.Abp.Http.Client.ClientProxyBase and ASP.NET Core OAuth handlers (default HttpCompletionOption.ResponseContentRead does not need manual disposal) - Fix "occured" -> "occurred" typos in two log lines - Remove unused using Microsoft.Extensions.Options from test
…r test Asserting GetType() == typeof(Exception) locks the test to the base type. The remaining message assertions already cover the intent of ensuring the underlying JSON parse error does not surface.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## rel-10.4 #25443 +/- ##
============================================
+ Coverage 49.30% 49.39% +0.09%
============================================
Files 3668 3670 +2
Lines 123343 123594 +251
Branches 9424 9452 +28
============================================
+ Hits 60816 61055 +239
- Misses 60702 60705 +3
- Partials 1825 1834 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Narrow GetAbpRemoteServiceErrorAsync catch to JSON deserialization exceptions (System.Text.Json + Newtonsoft) so OOM and other runtime errors are no longer swallowed - Dispose HttpResponseMessage in DownloadSourceCodeContentAsync via finally block, matching the pattern used by sibling methods - Use generic EnsureSuccessfulHttpResponseAsync for user-supplied TemplateSource downloads so non-abp.io 401/403 responses don't show a misleading abp.io license hint - Add tests for Newtonsoft JsonException handling and non-JSON exception propagation
- Use CliUrls.WwwAbpIo instead of hardcoded abp.io host/URL in the 401/403 license hint, so dev/staging environments show the right URL - Include server-provided RemoteServiceErrorResponse details (e.g. Code: LicenseExpired) in the CliUsageException message when available
enisn
approved these changes
May 16, 2026
1 task
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.
Fixes #25403.
When abp.io rejects a CLI download (HTTP 403 + HTML error page), the CLI used to surface
'<' is an invalid start of a valuewith no hint about license/auth.RemoteServiceExceptionHandler.GetAbpRemoteServiceErrorAsyncnow catches bothSystem.Text.Json.JsonExceptionandNewtonsoft.Json.JsonException(was onlyNewtonsoft.Json.JsonReaderException, which the activeAbpSystemTextJsonSerializernever throws).CliUsageExceptionwith anabp login/ license hint. User-supplied--template-sourceURLs use the generic handler.Added unit tests for
RemoteServiceExceptionHandler.