Retry unread requests after FreshRSS reauthentication - #17
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4671aa1d7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| r = request_unread(token, n, category) | ||
| r.raise_for_status() |
There was a problem hiding this comment.
Invalidate a token rejected by the retry
When the reauthenticated request also returns 401 or 403, this path calls raise_for_status() without clearing the newly cached token. Every subsequent client request therefore first sends a guaranteed-to-fail unread request with that known-rejected token before logging in and retrying, adding an avoidable upstream call and up to a timeout's worth of latency during persistent authentication or permission failures. The retry token should be invalidated on these statuses even though no further retry is attempted in the current request.
Useful? React with 👍 / 👎.
Motivation
401/403is received.Description
AUTH_TOKEN_LOCKand serializeAUTH_TOKENreads, login acquisition, and token writes insideget_greader_tokenusing the lock.request_unread(token, n, category).freshrss_unreadto callrequest_unread, and if the first response has status401or403invalidate the cached token (only if it matches the token used), obtain a new token, and retry the upstream request exactly once.tests/test_main.py.Testing
uv run pytest -qwhich completed successfully with12 passed.python -m compileall -q main.py tests/test_main.pyand static checks withgit diff --check(no issues).pytest -qin the system Python environment failed during collection due to a missingfastapidependency, while the project-managed test command above passed.Codex Task