Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 batch operation cannot post attribute for custom pydantic object #369

Open
djs0109 opened this issue Jan 8, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@djs0109
Copy link
Contributor

djs0109 commented Jan 8, 2025

Describe the bug
V2 batch operation update( )cannot post attributes when using custom pydantic object (For example inherited from the ContextEntity/ContextEntityKeyValues)

To Fix
Add SerializeAsAny annotation to the entities. Otherwise update.model_dump() will only serialize the object based on the schema, i.e., the ContextEntity or ContextEntityKeyValues. Therefore, only predefined attribute will be serialized, such as id and type.

class Update(BaseModel):
    """
    Model for update action
    """

    action_type: Union[ActionType, str] = Field(
        alias="actionType",
        description="actionType, to specify the kind of update action to do: "
        "either append, appendStrict, update, delete, or replace. ",
    )
    entities: SerializeAsAny[List[Union[ContextEntity, ContextEntityKeyValues]]] = Field(
        description="an array of entities, each entity specified using the "
        "JSON entity representation format "
    )
@djs0109 djs0109 added the bug Something isn't working label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant