Skip to content

feat: show readable message for HTML error responses#1038

Open
katerina20 wants to merge 1 commit into
mainfrom
feat/html_error
Open

feat: show readable message for HTML error responses#1038
katerina20 wants to merge 1 commit into
mainfrom
feat/html_error

Conversation

@katerina20

Copy link
Copy Markdown
Collaborator

No description provided.

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.95238% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.71%. Comparing base (f7534dc) to head (b97a5b0).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...com/crowdin/cli/client/CrowdinJsonTransformer.java 82.36% 2 Missing and 7 partials ⚠️
...java/com/crowdin/cli/client/CrowdinClientCore.java 72.73% 0 Missing and 3 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CrowdinJsonTransformer to detect HTML bodies and convert them into a readable HttpException.
  • Formats HTML error responses in CrowdinClientCore with 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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants