Skip to content

[FIX] currency_rate_update_xe: add User-Agent header to fix xe.com 403 blocking#234

Open
mohamedhagag wants to merge 1 commit into
OCA:18.0from
mohamedhagag:18.0
Open

[FIX] currency_rate_update_xe: add User-Agent header to fix xe.com 403 blocking#234
mohamedhagag wants to merge 1 commit into
OCA:18.0from
mohamedhagag:18.0

Conversation

@mohamedhagag

Copy link
Copy Markdown

Summary

  • xe.com started blocking requests without a User-Agent header around May 2025, returning HTTP 403. The code sent requests with Python's default python-requests/x.x.x UA which is trivially bot-filtered.
  • The _parse_data method silently returned an empty dict on a 403 page (0 rows found), so no rates were written and no error was raised — making the breakage invisible in logs.
  • Switch base_url from http:// to https:// to avoid an unnecessary redirect on every call.

Changes

  • Add User-Agent browser header to _request_data
  • Call response.raise_for_status() and handle HTTPError separately so HTTP-level failures surface as a meaningful UserError in Odoo instead of silently producing empty results
  • Use https:// for the base URL

Test plan

  • Configure a XE provider for EGP (or any currency) and trigger a manual update — rates should populate correctly
  • Confirm the fix works for both _get_latest_rate and _get_historical_rate paths

🤖 Generated with Claude Code

xe.com started blocking requests without a User-Agent header around
May 2025, returning HTTP 403 which silently produced empty rate results.
Add a browser User-Agent, call raise_for_status() so errors surface
as a proper UserError, and switch the base URL to HTTPS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@OCA-git-bot OCA-git-bot added mod:currency_rate_update_xe Module currency_rate_update_xe series:18.0 labels Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:currency_rate_update_xe Module currency_rate_update_xe series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants