Repository navigation
Conversation
`_serialize_value_with_schema` stored pydantic models with `model_dump()`, which keeps `datetime`, `date`, `UUID` and `Decimal` values. With snapshot saving enabled, `json.dump` then failed and a breakpoint raised `TypeError` instead of `BreakpointException`, leaving a half-written snapshot file. Use `model_dump(mode="json")`; deserialization already goes through `model_validate`, which parses the values back. Fixes deepset-ai#13490
emreocell
requested review from
bogdankostic
and
a balanced review from Copilot
and removed request for
a team
November 17, 2026 14:16
Contributor
|
@emreocell is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
_serialize_value_with_schemastored pydantic models withmodel_dump(), which keeps Python objects such asdatetime,date,UUIDandDecimal. WithHAYSTACK_PIPELINE_SNAPSHOT_SAVE_ENABLEDset,json.dumpin_save_pipeline_snapshotthen failed, so a breakpoint raisedTypeError: Object of type datetime is not JSON serializableinstead ofBreakpointExceptionand left a half-written snapshot file.The fix uses
model_dump(mode="json"). Deserialization already goes throughmodel_validate, which parses the JSON-mode values back into the original field types. The same helper is used for theAgentState, which benefits too. A release note is included.This only covers the pydantic-model path from the issue. It does not touch typed values inside
Document.meta(that is the scope of #13538).How did you test it?
test_serialize_pydantic_model_with_non_json_fields_is_json_safe(datetime/date/UUID/Decimal JSON round trip) and new end-to-end testtest_breakpoint_with_pydantic_model_with_datetime_field_saves_resumable_snapshot(the breakpoint writes a snapshot file,load_pipeline_snapshot+ resume returns the same model). Both fail without the fix (TypeError: Object of type datetime is not JSON serializable) and pass with it. The script from the issue also went fromTypeErrortoBreakpointException.hatch run test:unit: 7568 passed, 49 skipped, 0 failed (before a rebase onto the latestmain; after the rebase I re-ran the two touched test files: 102 passed).hatch run test:types(mypy): no issues.hatch run fmtdoes not work on Windows because of the;separator in the script). Integration/slow tests and pre-commit hooks were not run; tested with Python 3.13 on Windows 11.Notes for the reviewer
Document.meta); as far as I can tell the two changes are independent. Happy to adjust if you prefer one consolidated change.bytesintostr,setintolistand enums into their value, all of whichmodel_validateconverts back. For field types pydantic cannot represent as JSON,model_dump(mode="json")now raisesPydanticSerializationErrorduring serialization; before, such values reachedjson.dumpand failed there anyway, and_serialize_with_field_fallbackhandles the failing field.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.