fix(scrapers): bad credentials detection and error message cleanup (#367)

## Problem

Wrong credentials produced garbled error messages (`"login failed: Login
failed: bad_credentials"`) and stale credentials remained cached after
failure, causing silent re-use on the next invocation.

## Solution

Standardize all scrapers to emit `"bad_credentials"` as a plain error
code, mapped to a human-readable string via `LOGIN_ERRORS` in
`constants.lua`. Fix `credentials.lua` to clear cached credentials on
failure in both the fresh-prompt and re-prompt paths. For AtCoder and
Codeforces, replace `wait_for_url` with `wait_for_function` to detect
the login error element immediately rather than sitting the full 10s
navigation timeout. Add "Remember me" checkbox on Codeforces login.
This commit is contained in:
Barrett Ruth 2026-03-07 17:58:25 -05:00 committed by GitHub
parent 573b335646
commit 771dbc7753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 67 additions and 40 deletions

View file

@ -344,7 +344,7 @@ class KattisScraper(BaseScraper):
print(json.dumps({"status": "logging_in"}), flush=True)
ok = await _do_kattis_login(client, username, password)
if not ok:
return self._submit_error("Login failed (bad credentials?)")
return self._submit_error("bad_credentials")
await _save_kattis_cookies(client)
print(json.dumps({"status": "submitting"}), flush=True)
@ -381,7 +381,7 @@ class KattisScraper(BaseScraper):
print(json.dumps({"status": "logging_in"}), flush=True)
ok = await _do_kattis_login(client, username, password)
if not ok:
return self._submit_error("Login failed (bad credentials?)")
return self._submit_error("bad_credentials")
await _save_kattis_cookies(client)
try:
r = await _do_submit()
@ -421,7 +421,7 @@ class KattisScraper(BaseScraper):
print(json.dumps({"status": "logging_in"}), flush=True)
ok = await _do_kattis_login(client, username, password)
if not ok:
return self._login_error("Login failed (bad credentials?)")
return self._login_error("bad_credentials")
await _save_kattis_cookies(client)
return LoginResult(
success=True,