fix: generate valid ObjectId for audit log entries

default_factory=PyObjectId produced "" (empty string) since
Annotated[str, ...] is a type annotation, not a callable factory.
Replace with lambda: str(ObjectId()) to generate a real unique ID.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-04-29 15:06:15 +01:00
parent 0d46c1440c
commit e48d63bdbd

View file

@ -86,7 +86,7 @@ class AuditLogSeverity(str, Enum):
class AuditLog(BaseModel):
"""Audit log entry model."""
id: Optional[PyObjectId] = Field(default_factory=PyObjectId, alias="_id")
id: Optional[PyObjectId] = Field(default_factory=lambda: str(ObjectId()), alias="_id")
# Core audit fields
timestamp: datetime = Field(default_factory=datetime.utcnow)