[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot]
2026-02-06 02:11:04 +00:00
committed by GitHub
parent cb2b3e07ba
commit 57f76c4072
2 changed files with 3 additions and 3 deletions

View File

@ -333,7 +333,7 @@ def validate_and_get_api_token(scope: str | None = None):
def _query_token_from_db(auth_token: str, scope: str | None) -> ApiToken:
"""
Query API token from database, update last_used_at, and cache the result.
Raises Unauthorized if token is invalid.
"""
with Session(db.engine, expire_on_commit=False) as session:
@ -354,7 +354,7 @@ def _query_token_from_db(auth_token: str, scope: str | None) -> ApiToken:
def _fetch_token_with_single_flight(auth_token: str, scope: str | None) -> ApiToken:
"""
Fetch token from DB with single-flight pattern using Redis lock.
Ensures only one concurrent request queries the database for the same token.
Falls back to direct query if lock acquisition fails.
"""

View File

@ -81,7 +81,7 @@ class ApiTokenCache:
# If it's already a Pydantic model, use model_dump_json directly
if isinstance(api_token, CachedApiToken):
return api_token.model_dump_json().encode("utf-8")
# Otherwise, convert from SQLAlchemy model to CachedApiToken first
cached = CachedApiToken(
id=str(api_token.id),