From 2eef8f480f14c0fa6b06fd55378d24cd45647acc Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 11 May 2026 14:05:35 +0100 Subject: [PATCH] Fix remaining 'Find Link' references and improve error messages - Rename index page title and heading to 'Missing Link' - Give a clear message for 429 rate limit errors - Include response body snippet in other unexpected API errors - Log warning when falling back to unauthenticated session Co-Authored-By: Claude Sonnet 4.6 --- add_links/api.py | 5 ++++- templates/index.html | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/add_links/api.py b/add_links/api.py index 5d8de19..6f57def 100644 --- a/add_links/api.py +++ b/add_links/api.py @@ -81,6 +81,7 @@ def _get_active_session() -> requests.sessions.Session: return g.oauth_session # type: ignore[return-value] except RuntimeError: pass + print("WARNING: using unauthenticated session", file=sys.stderr) return get_session() @@ -96,7 +97,9 @@ def api_get(params: StrDict) -> StrDict: print(f"Response body: {r.text!r}", file=sys.stderr) if webpage_error in r.text: raise MediawikiError(webpage_error) - raise MediawikiError(f"HTTP {r.status_code}: unexpected response from Wikipedia API") + if r.status_code == 429: + raise MediawikiError("Wikipedia rate limit exceeded — wait a moment and try again.") + raise MediawikiError(f"HTTP {r.status_code}: {r.text[:200]!r}") check_for_error(ret) return ret diff --git a/templates/index.html b/templates/index.html index af5314b..11c14ec 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,12 +1,12 @@ {% extends "base.html" %} -{% block title %}Find Link{% endblock %} +{% block title %}Missing Link{% endblock %} {% block content %}
-

Find Link

+

Missing Link

Find unlinked mentions of a Wikipedia article and add the links.