From eccd465f8954bfd49c3f7d8f02446bc2aa5c4338 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 26 Sep 2026 14:28:13 +0200 Subject: fix(node,client): query TMDB only once a language is chosen, in that language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TMDB fiches are fetched lazily, on browse, and the fetch used to run whatever the moment it was first triggered — routinely before the operator had opened settings and picked a language, so it queried in TMDB's English default. Then the fiche was cached by tmdb_id alone, with no note of language and a 30-day TTL, so switching to the intended language afterwards changed nothing: the English fiche was served until it expired. The operator's only recourse was to find and wipe the cache by hand (found live 2026-09-26: a whole library indexed in English although "Français" had been chosen). Two rules now, both there to make the first fetch the right language rather than English-then-corrected, and to stop the doubled requests that eventually get a node rate-limited: - No language configured, no query. media_meta_req/season_meta_req answer confidence 0 and make no TMDB call while tmdb_language is unset; the fetch waits for the operator's choice, so the first (and only) query is in it. English is now a first-class choice (en-US), not the default of skipping the setting. - Changing the language wipes the metadata cache (ops.set_tmdb_config), so the new language takes effect on an already-browsed library. The file->tmdb matches are language-independent and kept. The client refetches on the tmdb_config_ack that carries the new language, so the grid updates without a page reload. docs/MESHBAY_DESIGN.md §9.7 states both rules; tests cover the gate and the cache wipe, and two existing handler harnesses now declare a language. Co-Authored-By: Claude Opus 4.8 --- packages/meshbay-node/tests/test_season_and_search_requests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'packages/meshbay-node/tests/test_season_and_search_requests.py') diff --git a/packages/meshbay-node/tests/test_season_and_search_requests.py b/packages/meshbay-node/tests/test_season_and_search_requests.py index 7e81e63..bec7df9 100644 --- a/packages/meshbay-node/tests/test_season_and_search_requests.py +++ b/packages/meshbay-node/tests/test_season_and_search_requests.py @@ -19,7 +19,10 @@ pytestmark = pytest.mark.asyncio def _session(media_cache=None, tmdb_client=None) -> WebRTCPeerSession: session = WebRTCPeerSession.__new__(WebRTCPeerSession) - session._ctx = {"media_cache": media_cache, "tmdb_client": tmdb_client} + # daemon_state carries a configured language: the gate (§9.7) holds every + # TMDB fetch until one is set, so these fetch/search tests must set one. + session._ctx = {"media_cache": media_cache, "tmdb_client": tmdb_client, + "daemon_state": {"tmdb_language": "en-US"}} session._group_id = None # Set because production always has one: `_dispatch_message` refuses every # message until the handshake settles `_user_id`, so a session reaching any -- cgit v1.2.3