[14.0][FIX] currency_rate_update_transferwise: avoid a zero-length date window - #235
Open
klodr wants to merge 1 commit into
Open
[14.0][FIX] currency_rate_update_transferwise: avoid a zero-length date window#235klodr wants to merge 1 commit into
klodr wants to merge 1 commit into
Conversation
…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>
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.
Problem
The provider builds its query with
"to": str(min(until, date_to)). When the window would collapse —date_from == date_to— that yieldsfrom == to, and the API rejects it:Odoo then logs, once per scheduled run:
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:
from=2026-08-04&to=2026-08-04from=2026-08-04&to=2026-08-05from=2026-08-05&to=2026-08-06from=2026-08-06&to=2026-08-07The 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_wisemigration PRs (#222, #223, #224, #225, #232) and in #219; they carry the equivalent fix.