Skip to content

Fix a bug where this SDK's internals fail to handle items restored using Pydantic etc. #1467

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

seratch
Copy link
Member

@seratch seratch commented Aug 14, 2025

This pull request resolves a known issue with serialized/deserialized items.

The most common one is TypeError: cannot pickle 'pydantic_core._pydantic_core.ValidatorIterator' object with the data loaded via Pydantic methods, but we've received similar reports with other objects too.

This pull request minimizes the use of copy.deepcopy() inside this SDK to eliminate the potential runtime errors.

@seratch seratch requested a review from rm-openai August 14, 2025 07:40
@seratch seratch self-assigned this Aug 14, 2025
@seratch seratch enabled auto-merge (squash) August 14, 2025 08:08
Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need such a complex change? Can't we just replace copy.deepcopy(foo) with list(foo) to make a copy of the container?

@seratch
Copy link
Member Author

seratch commented Aug 15, 2025

@rm-openai yeah, we can simplify the implementation. I think I can remove the memo and deepcopy for basic objects and primitives. anything else you want to remove?

@rm-openai
Copy link
Collaborator

I think we don't need anything except replace all copy.deepcopy(...) with list(...)

@seratch
Copy link
Member Author

seratch commented Aug 15, 2025

@rm-openai Thanks for clarifying. Since we'd been using copy.deepcopy for union type values (str | list) and potentially we may encounter this issue with other types such as set, tuple. So, I think having this simplified common utility should be helpful for us to more easily avoid making the same mistakes in the future.

That said, if you prefer a different implementation, you can come up with your own changes. I will be happy to be a reviewer instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants