From d5de1a63d4d0ae4b51e910eeb0acce159a508213 Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:36:26 +0800 Subject: [PATCH] fix: eager-load server defaults on StorageObjects to avoid MissingGreenlet publish_version -> create_server_object_payload -> storage_payload reads item.created_at on a sync helper. Without eager_defaults, server-default columns stay unloaded after INSERT, the next sync read triggers a lazy refresh through the async driver, and MissingGreenlet fires. Enable mapper-level eager_defaults on StorageObjects so server-default columns (created_at, updated_at, ...) are round-tripped into the ORM object immediately after INSERT. No other table or session config touched. Co-Authored-By: Claude Fable 5 --- common/src/common/db/models/storage.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/src/common/db/models/storage.py b/common/src/common/db/models/storage.py index 85edf86..0cd7daf 100644 --- a/common/src/common/db/models/storage.py +++ b/common/src/common/db/models/storage.py @@ -10,6 +10,13 @@ from common.db.base import Base class StorageObjects(Base): __tablename__ = "storage_objects" + # Force SQLAlchemy to round-trip server-default columns (created_at, + # updated_at, ...) via a follow-up SELECT after INSERT. Without this, + # attributes populated by `server_default` stay unloaded on the ORM + # object and the next sync read (e.g. storage_payload in storage_api.py) + # triggers a lazy refresh through the async driver, which raises + # MissingGreenlet because the read happens outside an awaitable. + __mapper_args__ = {"eager_defaults": "auto"} __table_args__ = ( Index("fk_storage_created_by", "created_by"), Index("idx_storage_content_hash", "content_hash"),