Skip to content

fix(core): restore MemoryMimeType enum after serialization roundtrip - #8313

Open
ZhengQiangZhang (LeonZhang778) wants to merge 1 commit into
microsoft:mainfrom
LeonZhang778:fix/memory-mime-type-roundtrip
Open

ZhengQiangZhang (LeonZhang778) wants to merge 1 commit into
microsoft:mainfrom
LeonZhang778:fix/memory-mime-type-roundtrip

Conversation

@LeonZhang778

Copy link
Copy Markdown

Fixes #8293

MemoryContent serialized mime_type enums to their string form via a field_serializer, but had no inverse validation on load, so after a dump_component()/load_component() (or save_state/load_state) roundtrip the enum degenerated to a plain str. Code that dispatches on content.mime_type == MemoryMimeType.X silently changed behavior after a save/load.

Add a field_validator that restores MemoryMimeType from its string value on load, while leaving custom MIME strings untouched.

Why are these changes needed?

Related issue number

Checks

Fixes microsoft#8293

MemoryContent serialized mime_type enums to their string form via a
field_serializer, but had no inverse validation on load, so after a
dump_component()/load_component() (or save_state/load_state) roundtrip
the enum degenerated to a plain str. Code that dispatches on
content.mime_type == MemoryMimeType.X silently changed behavior after
a save/load.

Add a field_validator that restores MemoryMimeType from its string
value on load, while leaving custom MIME strings untouched.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: MemoryContent.mime_type enum degenerates to str after dump/load roundtrip (ListMemory)

1 participant