Revert "feat: add input data to pydantic validation error logging" (#5847)

Revert "feat: add input data to pydantic validation error logging (#5748)"

This reverts commit 0a61c0c2c1fa0e09867120af93f17ab6304a795f.
This commit is contained in:
Sarah Wooders
2025-10-29 20:50:15 -07:00
committed by Caren Thomas
parent 24a14490d8
commit f61a4b8319
2 changed files with 4 additions and 19 deletions

View File

@@ -1,10 +1,10 @@
import uuid
from datetime import datetime
from logging import getLogger
from typing import Any, Optional
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, ConfigDict, Field, ValidationError, field_validator, model_validator
from pydantic import BaseModel, ConfigDict, Field, field_validator
# from: https://gist.github.com/norton120/22242eadb80bf2cf1dd54a961b151c61
@@ -12,21 +12,7 @@ from pydantic import BaseModel, ConfigDict, Field, ValidationError, field_valida
logger = getLogger(__name__)
class LoggingBaseModel(BaseModel):
"""Base model with global validation error logging for all pydantic models."""
@model_validator(mode="wrap")
@classmethod
def _log_validation_errors(cls, values: Any, handler, info):
"""Global validator to log validation errors with the full data that failed validation."""
try:
return handler(values)
except ValidationError as e:
logger.error(f"Pydantic validation error in {cls.__name__}. Input data: {values}. Error: {e}")
raise
class LettaBase(LoggingBaseModel):
class LettaBase(BaseModel):
"""Base schema for Letta schemas (does not include model provider schemas, e.g. OpenAI)"""
model_config = ConfigDict(

View File

@@ -5,7 +5,6 @@ from typing import Annotated, List, Literal, Optional, Union
from pydantic import BaseModel, Field, field_serializer, field_validator
from letta.schemas.letta_base import LoggingBaseModel
from letta.schemas.letta_message_content import (
LettaAssistantMessageContentUnion,
LettaUserMessageContentUnion,
@@ -23,7 +22,7 @@ class MessageReturnType(str, Enum):
tool = "tool"
class MessageReturn(LoggingBaseModel):
class MessageReturn(BaseModel):
type: MessageReturnType = Field(..., description="The message type to be created.")