Skip to content

aredis_om and pydantic-v2 @model_validator RecursionError  #583

Closed
@brodyreiss1

Description

@brodyreiss1

When trying to add a pydantic v2 model validator to my aredis_om JsonModel, a RecursionError occurs. When testing both aredis_om and the validator separately, both work without error. When testing together a maximum depth search error occurs.

Here is example code that recreates this issue...

from aredis_om import JsonModel
from pydantic import model_validator


class Test(JsonModel):
    name: str

    @model_validator(mode='after')
    async def create_name(self):
        self.name = 'this is different'
        return self

    @classmethod
    async def create(cls, name):
        test = cls(name=name)
        await test.save()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions