fix(instrumentation): serialize pydantic model attributes in json mode#2813
Merged
axiomofjoy merged 3 commits intoArize-ai:mainfrom Apr 23, 2026
Merged
Conversation
Contributor
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
axiomofjoy
approved these changes
Mar 26, 2026
1 task
Replace test_attributes.py (which tested the private _json_serialize helper) with a test in test_manual_instrumentation.py that exercises get_output_attributes, the public-facing function. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ac040fa to
f63aee2
Compare
Merged
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.
Pydantic models with non-JSON dict keys (for example
Enum/UUID) can fail in_json_serializewith:TypeError: keys must be str, int, float, bool or None, not ...Switch Pydantic serialization in
_attributes.pyfrommodel_dump()tomodel_dump(mode="json")so output is JSON-compatible beforejson.dumps.Note
Medium Risk
Changes how Pydantic models are converted before
json.dumps, which can slightly alter emitted attribute payloads and affect downstream consumers expecting the previous representation.Overview
Fixes
_json_serializefor PydanticBaseModelinputs by usingmodel_dump(mode="json")so non-JSON dict keys (e.g.,Enum,UUID) are coerced into JSON-compatible keys before encoding.Adds a unit test covering serialization of a Pydantic model with mixed key types to prevent regressions.
Written by Cursor Bugbot for commit 65d5dae. This will update automatically on new commits. Configure here.