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 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-05-11 14:05:35 +01:00
parent c9b4e2face
commit 2eef8f480f
2 changed files with 6 additions and 3 deletions

View file

@ -81,6 +81,7 @@ def _get_active_session() -> requests.sessions.Session:
return g.oauth_session # type: ignore[return-value] return g.oauth_session # type: ignore[return-value]
except RuntimeError: except RuntimeError:
pass pass
print("WARNING: using unauthenticated session", file=sys.stderr)
return get_session() return get_session()
@ -96,7 +97,9 @@ def api_get(params: StrDict) -> StrDict:
print(f"Response body: {r.text!r}", file=sys.stderr) print(f"Response body: {r.text!r}", file=sys.stderr)
if webpage_error in r.text: if webpage_error in r.text:
raise MediawikiError(webpage_error) 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) check_for_error(ret)
return ret return ret

View file

@ -1,12 +1,12 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Find Link{% endblock %} {% block title %}Missing Link{% endblock %}
{% block content %} {% block content %}
<div class="container"> <div class="container">
<div class="row justify-content-center mt-5"> <div class="row justify-content-center mt-5">
<div class="col-md-6 text-center"> <div class="col-md-6 text-center">
<h1 class="mb-2">Find Link</h1> <h1 class="mb-2">Missing Link</h1>
<p class="text-muted mb-4">Find unlinked mentions of a Wikipedia article and add the links.</p> <p class="text-muted mb-4">Find unlinked mentions of a Wikipedia article and add the links.</p>
<form class="d-flex gap-2 justify-content-center" action="{{ url_for('index') }}"> <form class="d-flex gap-2 justify-content-center" action="{{ url_for('index') }}">
<input class="form-control" name="q" placeholder="Article title…" style="max-width:360px" autofocus> <input class="form-control" name="q" placeholder="Article title…" style="max-width:360px" autofocus>