Repository navigation
Conversation
A class passed as a value, such as a pydantic model given as an output schema, fell through to the instance branches. Pydantic classes dumped their slot descriptors, plain classes dumped their namespace, and dataclass classes failed in asdict(). Return "<class 'module.QualName'>" for any class object instead. The failure fallback in default() also returned a string with embedded quotes, which were then JSON-escaped a second time. Drop them; encode() keeps its quotes because its return value is the final JSON.
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.
What does this PR do?
Fixes langfuse/langfuse#20157
EventSerializernow returns<class 'module.QualName'>for class objects instead of dumping their namespace (mappingproxy/ descriptor entries) or falling back to a double-quoted string. This is what an@observe-decorated function records for arguments likeschema=Invoice. The class check sits after the plain JSON types and before the depth, dataclass,BaseModel,__slots__andvars()branches; those only handle instances, so nothing else changes. The name is built from__module__and__qualname__rather thanrepr()so a metaclass__repr__(e.g. Enum classes) can't change it.It also removes the embedded quotes from the final fallback in
default(): the value was"\"<not serializable object of type: X>\""in the JSON. Theencode()fallback, which produces the whole document, keeps its quotes.Not covered: generic aliases and unions such as
list[Invoice]orInvoice | Noneare nottypeinstances and still go through the existing branches; happy to handle them here or in a follow-up.Type of change
Verification
List the main commands you ran:
Checklist
code_review.md..env.templateif needed.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
EventSerializernow records class objects as<class 'module.QualName'>instead of walking their fields.Reviews (2) · Last reviewed commit: "fix(serializer): record class objects as..." · Reviewed by Greptile