Skip to content

Weblate HTTP error handling: structured parsing for POST response errors#45

Merged
wpak-ai merged 2 commits into
cppalliance:masterfrom
whisper67265:fix/http-error-handling
Jul 2, 2026
Merged

Weblate HTTP error handling: structured parsing for POST response errors#45
wpak-ai merged 2 commits into
cppalliance:masterfrom
whisper67265:fix/http-error-handling

Conversation

@whisper67265

@whisper67265 whisper67265 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Close #39.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages for failed translation requests with clearer, categorized reasons (including rate limiting, server/network issues, and unexpected HTTP statuses).
    • Added more targeted “what to do next” remediation guidance (including retry-later messaging for transient failures).
    • When available, response details are now included to help pinpoint the underlying issue.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b49f5f14-bbeb-4aa2-9a61-ee7fe0afb573

📥 Commits

Reviewing files that changed from the base of the PR and between a2f2651 and d12e7de.

📒 Files selected for processing (2)
  • .github/workflows/assets/translation.sh
  • tests/test_trigger_weblate.bats
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/assets/translation.sh

📝 Walkthrough

Walkthrough

Adds structured Weblate POST failure classification in trigger_weblate, extends curl failure simulation in tests, and updates bats coverage for HTTP and curl error cases with specific remediation output.

Changes

Weblate error classification

Layer / File(s) Summary
Error classification helper
.github/workflows/assets/translation.sh
Adds report_weblate_post_error(curl_exit, http_code, resp_file), which selects messages and remediation based on curl exit code or HTTP status, logs via phase_err, and prints parsed JSON response detail.
Wire helper into trigger_weblate
.github/workflows/assets/translation.sh
Replaces prior generic phase_err + cat logging in the curl-failure and unexpected-status branches with calls to the new helper.
Curl stub exit simulation
tests/helpers/http_mock.bash
Adds MOCK_CURL_EXIT support to the curl stub for simulating arbitrary exit codes, and unsets it during cleanup.
Updated bats assertions for error scenarios
tests/test_trigger_weblate.bats
Replaces and expands tests for HTTP 403, 409, 405, 301, timeout, and connection-failure scenarios, and adds coverage for HTTP 429 and 503 with specific classification and remediation text.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant trigger_weblate
  participant curl
  participant report_weblate_post_error
  trigger_weblate->>curl: POST request to Weblate
  curl-->>trigger_weblate: exit code / HTTP status
  alt curl fails
    trigger_weblate->>report_weblate_post_error: curl_exit, resp_file
  else unexpected HTTP status
    trigger_weblate->>report_weblate_post_error: http_code, resp_file
  end
  report_weblate_post_error-->>trigger_weblate: classified message + remediation hint
Loading

Possibly related PRs

Suggested reviewers: henry0816191, wpak-ai

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR covers error classification and test cases, but the summary only shows .detail parsing, not the required .message and .error fields. Parse and log .detail, .message, and .error from JSON responses, then add or adjust tests to verify all three fields.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change to Weblate POST error handling.
Out of Scope Changes check ✅ Passed All changes are confined to Weblate error handling code and related tests, with no unrelated features introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/assets/translation.sh:
- Around line 169-181: The HTTP status handling in the Weblate response `case`
treats many 4xx errors as server/network failures because they fall through to
the default branch. Add an explicit catch-all 4xx branch in the same `case` so
any unhandled 4xx is labeled as a client/payload error with a remediation that
tells the user to inspect the request. Keep the `5??` branch for true
server/network failures, and make the `*)` default distinct rather than
duplicating the 5xx message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 20f93930-093f-46e0-8599-4408bb4b0d33

📥 Commits

Reviewing files that changed from the base of the PR and between ac0c38f and a2f2651.

📒 Files selected for processing (3)
  • .github/workflows/assets/translation.sh
  • tests/helpers/http_mock.bash
  • tests/test_trigger_weblate.bats

Comment thread .github/workflows/assets/translation.sh
@whisper67265 whisper67265 requested a review from henry0816191 July 2, 2026 20:13
@whisper67265 whisper67265 requested a review from wpak-ai July 2, 2026 23:16
@wpak-ai wpak-ai merged commit 363c320 into cppalliance:master Jul 2, 2026
3 checks passed
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.

Weblate HTTP error handling: structured parsing for POST response errors

3 participants