From a79506c18fffdfe920de6324fbd789095a88a01c Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 30 Aug 2026 21:43:33 +0200 Subject: [PATCH] fix: the release preview sends the app's User-Agent, which Commons requires Co-Authored-By: Claude Opus 5 (1M context) --- tool/preview_release.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tool/preview_release.py b/tool/preview_release.py index c0df693..e6f41fa 100755 --- a/tool/preview_release.py +++ b/tool/preview_release.py @@ -33,6 +33,7 @@ from typing import Final import httpx from signal_bot.announce import render +from signal_bot.app import HTTP_TIMEOUT_SECONDS, USER_AGENT from signal_bot.changelog import load, since from signal_bot.config_env import load_config from signal_bot.http_client import ImageFetcher @@ -109,9 +110,16 @@ async def send_preview(group: str, ordinal: int, *, print_only: bool) -> None: if print_only: sys.stdout.write("== not sent (--print-only)\n") return + sys.stdout.flush() config = load_config() - async with httpx.AsyncClient(timeout=60.0) as client: + # The app's client, headers and all: Wikimedia answers 403 to httpx's + # default User-Agent, so a bare client here would fail exactly where the + # bot succeeds -- which is the opposite of what a preview is for. + async with httpx.AsyncClient( + timeout=HTTP_TIMEOUT_SECONDS, + headers={"User-Agent": USER_AGENT}, + ) as client: group_id = await group_id_for(client, config.groups_url, group) portraits = PortraitCache(ImageFetcher(client), config.commons_api_url) image = await portraits.get_base64(pope)