feat: show readable message for HTML error responses#1038
Open
katerina20 wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1038 +/- ##
============================================
+ Coverage 65.51% 65.71% +0.20%
- Complexity 1796 1820 +24
============================================
Files 255 256 +1
Lines 7363 7429 +66
Branches 1120 1129 +9
============================================
+ Hits 4823 4881 +58
- Misses 1899 1900 +1
- Partials 641 648 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves the CLI’s error reporting when the Crowdin API client receives an unexpected HTML response (common with proxies/gateways), ensuring users see a readable message rather than a JSON parse error.
Changes:
- Introduces
CrowdinJsonTransformerto detect HTML bodies and convert them into a readableHttpException. - Formats HTML error responses in
CrowdinClientCorewith a dedicated, user-friendly message (including extracted body text). - Adds unit tests to validate HTML detection/extraction and readable error messages.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/crowdin/cli/client/CrowdinJsonTransformer.java | Adds a delegating JSON transformer that detects HTML and builds a readable HttpException. |
| src/main/java/com/crowdin/cli/client/Clients.java | Switches client configuration to use CrowdinJsonTransformer instead of raw JacksonJsonTransformer. |
| src/main/java/com/crowdin/cli/client/CrowdinClientCore.java | Detects HTML responses in HttpException and formats a clearer error message for users. |
| src/main/resources/messages/messages.properties | Adds a localized message explaining why an HTML response might occur. |
| src/test/java/com/crowdin/cli/client/CrowdinJsonTransformerTest.java | Adds targeted unit tests for HTML parsing/detection behavior and delegation to Jackson. |
| src/test/java/com/crowdin/cli/client/CrowdinProjectClientTest.java | Adds an integration-style test ensuring the final thrown message is readable for HTML responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+131
to
+134
| String httpResponse = e.getHttpResponse(); | ||
| if (CrowdinJsonTransformer.looksLikeHtml(httpResponse)) { | ||
| throw new RuntimeException(formatHtmlResponseError(e, httpResponse)); | ||
| } |
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.
No description provided.