Repository navigation
fix: serialize credential expiry to ISO string for PostgreSQL/asyncpg compatibility - #444
Merged
Merged
Conversation
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.
修复问题 / Problem
在配置了
POSTGRESQL_URI(使用asyncpg驱动)的环境下,后台刷新 Token (refresh_token) 时会报错HTTP 500,错误日志如下:原因分析 / Cause
src/storage/database.py中,AntigravityCredential.expiry字段定义为Mapped[str] = mapped_column(Text)。src/credential_manager.py的refresh_token函数中,credential_data["expiry"] = creds.expires_at直接传入了datetime.datetime对象。asyncpg对 SQL 参数类型要求严格,当检测到目标列为VARCHAR/Text时,传入datetime.datetime会抛出类型不匹配异常。解决方案 / Solution
src/credential_manager.py中,将creds.expires_at统一转换为.isoformat()字符串(与其他模块如src/auth.py和src/google_oauth_api.py逻辑保持一致)。src/storage/database.py的store_credential中增加兼容性兜底,确保入库的expiry始终为字符串。感谢作者的开源重构工作!❤️