Skip to content

[14.0][FIX] currency_rate_update_transferwise: avoid a zero-length date window - #235

Open
klodr wants to merge 1 commit into
OCA:14.0from
klodr:14.0-fix-transferwise-zero-window
Open

[14.0][FIX] currency_rate_update_transferwise: avoid a zero-length date window#235
klodr wants to merge 1 commit into
OCA:14.0from
klodr:14.0-fix-transferwise-zero-window

Conversation

@klodr

@klodr klodr commented Aug 5, 2026

Copy link
Copy Markdown

Problem

The provider builds its query with "to": str(min(until, date_to)). When the window would collapse — date_from == date_to — that yields from == to, and the API rejects it:

GET /v1/rates?from=2026-08-04&to=2026-08-04&source=USD&target=EUR&group=day
→ 400 Bad Request

Odoo then logs, once per scheduled run:

Currency Rate Provider "…" failed to obtain data since 2026-08-04 until 2026-08-04:
400 Client Error: Bad Request

Why it went unnoticed

The failure is intermittent by construction. A single-day window only happens once the rates are already up to date — the steady state of a daily cron. As soon as two or more days are missing the window is valid again, the next run catches up, and the gap disappears from the rate table. On a production instance I found ~10 missing days over a 36-day span with no visible symptom other than these log lines.

Fix

Widen the window by one day when it would collapse. Verified against the live API:

window response
from=2026-08-04&to=2026-08-04 400
from=2026-08-04&to=2026-08-05 200 — returns the 4th only
from=2026-08-05&to=2026-08-06 200 — returns the 5th only
from=2026-08-06&to=2026-08-07 404 — window entirely in the future

The endpoint only ever returns the days it actually has, so asking for one day ahead creates no spurious rate.

The same defect is present in the currency_rate_update_wise migration PRs (#222, #223, #224, #225, #232) and in #219; they carry the equivalent fix.

…ndow

The API answers HTTP 400 when the "from" and "to" query parameters are
equal:

  GET /v1/rates?from=2026-08-04&to=2026-08-04&source=USD&target=EUR&group=day
  -> 400 Bad Request

That is exactly the shape of a scheduled run once the rates are up to
date: the provider then asks for the single missing day. The failure is
therefore intermittent — it only shows up when no more than one day is
missing, which is the steady state of a daily cron, and a later run that
has several days to catch up succeeds and hides it.

Widen the window by one day when it would collapse. The endpoint only
returns the days it actually has, so no spurious rate is created.

Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
@OCA-git-bot OCA-git-bot added series:14.0 mod:currency_rate_update_transferwise Module currency_rate_update_transferwise labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:currency_rate_update_transferwise Module currency_rate_update_transferwise series:14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants