Skip to content

JSON repository appears to call item serialization twice on update vs. replace #50

@gregoryfoster

Description

@gregoryfoster

Building on the JSONDirectoryRepo framework, I implemented a model with a Pydantic field_serializer to convert a Decimal value to string. That worked well when calling the BaseRepo methods to add or replace files in the repository, but I turned up an unusual error when attempting to call update. I haven't tried to track it down more because I am using replace as a workaround.

From what I can tell, it appears that the update call attempts to serialize the model twice, causing a failure when the field_serializer is handed a string instead of the expected Decimal value. That points to a likely unnecessary call to item_to_dict somewhere along the way, probably in the JSONDirectoryRepo override of update.

I'm new to the codebase, and using @ManiMozaffar's fork to support Pydantic v2 - but the error appears to be in the mainline codebase. I'll attach the traceback output as a comment for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions