feat(launch): friendly GitHub-limit message on Generate; document the score formula

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shay
2026-11-30 06:12:22 -08:00
co-authored by Claude Opus 5.5
parent b737a0171e
commit d907815f19
7 changed files with 78 additions and 1 deletions
+4
View File
@@ -87,6 +87,10 @@ def get_data(username: str):
t0 = time.monotonic()
try:
data = github.fetch_github_data(username, token=config.GITHUB_PAT)
except github.GitHubTransientError as e:
analytics.record_fetch(username, 503, int((time.monotonic() - t0) * 1000))
log.warning("github fetch rate-limited for %s: %s", username, e)
return jsonify({"error": "github_rate_limited"}), 503
except Exception:
analytics.record_fetch(username, 502, int((time.monotonic() - t0) * 1000))
log.exception("github fetch failed for %s", username)
+12
View File
@@ -203,3 +203,15 @@ def test_rate_limit_body_is_not_classified_as_valid_user_data():
assert apimod._is_github_not_found({"user": {"login": "alice"}}) is False
assert apimod._is_github_not_found({"user": {"message": "Not Found"}}) is True
assert apimod._is_github_not_found({"user": None}) is True
def test_data_miss_rate_limited_returns_503(client, monkeypatch):
# A spent GitHub quota is transient: the fetcher says so (503), so the
# generator can tell the user the card will build after the reset.
def fake_fetch(*_a, **_kw):
raise apimod.github.GitHubTransientError("REST rate limit exhausted")
monkeypatch.setattr(apimod.github, "fetch_github_data", fake_fetch)
r = client.get("/data/alice", headers={"X-Internal-Token": "secret"})
assert r.status_code == 503
assert r.get_json() == {"error": "github_rate_limited"}
assert dbmod.get_user("alice") is None