stop infinite retry loop on rejected Lichess tokens
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 12s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 12s
A gamer's periodic check would get permanently stuck if their stored token was revoked/expired: our stats API collapsed both "Lichess rejected the token" (401/403, permanent) and genuine transient errors into the same 502 response, so the bot treated an invalid token exactly like a network blip — retrying the same window forever at a capped 300s backoff, never advancing the checkpoint (observed in prod: Dor1zz stuck for 100+ consecutive errors over 8+ hours, admin alerts firing every 25 failures). Preserve the distinction that already existed one layer down (lichess_client.py already tells 401/403 apart from other failures) instead of collapsing it in stats_service.py: add PuzzleOfPeriodResponse.auth_failed, have main.py return 401 specifically for that case, and have the bot raise a distinct InvalidTokenError instead of returning None. On InvalidTokenError, the bot now clears the token for that pair, notifies the user to reconnect via /addtoken, and continues tracking games normally instead of stalling forever.
This commit is contained in:
parent
8080921141
commit
619c00aa06
7 changed files with 70 additions and 16 deletions
|
|
@ -839,6 +839,7 @@ class StatsService:
|
|||
return PuzzleOfPeriodResponse(
|
||||
message="Неверный токен авторизации или доступ запрещен",
|
||||
success=False,
|
||||
auth_failed=True,
|
||||
period_start=since_ms,
|
||||
period_end=until_ms,
|
||||
max_puzzles=max_puzzles,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue