fix: Redis token cache bug fixes and docs#32
Merged
koljahuang merged 4 commits intomainfrom Apr 21, 2026
Merged
Conversation
added 3 commits
April 21, 2026 09:20
_cache_token accessed token.allowed_models which no longer exists on APIToken (model restrictions moved to models relationship). This caused AttributeError silently caught by the fallback, making Redis cache never actually work. Also add warning log in the fallback path.
… docs Add Redis cache layer description (TTL, graceful degradation, cache invalidation, key format) to performance docs. Update key files lists in security docs to include redis.py and token_cache.py.
Move logging import to module level, drop exc_info from hot-path fallback warning, remove unused validate_token_for_model that referenced non-existent allowed_models field.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AttributeErrorontoken.allowed_modelsinCachedTokenServicethat silently broke Redis token caching (cache never worked)_validate_token_with_cachefor easier debuggingvalidate_token_for_modeldependency (referenced non-existentallowed_modelsfield, unused)import loggingRoot cause
token_cache.pyreferencedtoken.allowed_modelswhich was removed from theAPITokenmodel when model restrictions moved to a separateModelrelationship. TheAttributeErrorwas caught byexcept Exceptionand silently fell back to DB every time.Test plan
token:{hash}key with TTL 300s)