fix: serialize Laminar span_context UUIDs as strings for JSON compatibility#2000
Merged
fix: serialize Laminar span_context UUIDs as strings for JSON compatibility#2000
Conversation
…bility Laminar.get_laminar_span_context_dict() returns uuid.UUID objects which are not JSON serializable. This caused PR review workflows to fail with: 'Object of type UUID is not JSON serializable' Fix by using get_laminar_span_context().model_dump(mode='json') which properly serializes UUIDs as strings. Co-authored-by: openhands <openhands@all-hands.dev>
Collaborator
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 Acceptable - Works but could be cleaner
Linus-Style Analysis:
This fix is pragmatic and direct - you identified a real production bug (100% PR review failure) and fixed it without over-engineering. The solution is simple: use the proper serialization method instead of the broken one.
VERDICT: ✅ Worth merging - Core logic is sound, one minor test improvement suggested
KEY INSIGHT: This is how bug fixes should be done - minimal change, direct solution, test to prevent regression. The only gap is demonstrating why the old code was broken.
Co-authored-by: openhands <openhands@all-hands.dev>
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.
Summary
Fixes a bug introduced in PR #1988 where
Laminar.get_laminar_span_context_dict()returnsuuid.UUIDobjects which are not JSON serializable, causing all PR review workflows to fail with:Root Cause
PR #1988 added code to capture span context for trace continuation:
However,
get_laminar_span_context_dict()returns a dict withuuid.UUIDobjects (not strings), which fails whenjson.dump()is called.Fix
Use
get_laminar_span_context().model_dump(mode="json")instead, which properly serializes UUIDs as strings:Impact
This bug caused 100% of PR review workflows using SDK code with PR #1988 to fail. After this fix, PR reviews should succeed again.
Testing
Added a test to verify trace data with span_context is JSON serializable, which would have caught this bug before merge.
@neubig can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:9167399-pythonRun
All tags pushed for this build
About Multi-Architecture Support
9167399-python) is a multi-arch manifest supporting both amd64 and arm649167399-python-amd64) are also available if needed