Fix serializer negative infinity#1684
Open
aryxnn wants to merge 2 commits into
Open
Conversation
added 2 commits
June 1, 2026 03:06
Allows propagate_attributes to accept and automatically convert non-string metadata values (int, float, bool) to strings instead of silently dropping them. This resolves tracing compatibility issues with LangGraph integrations.
|
Aryan Srivastava seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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 #
Type of change
Verification
List the main commands you ran:
Checklist
code_review.md..env.templateif needed.Greptile Summary
This PR fixes two bugs: negative infinity floats were always serialised as
"Infinity"instead of"-Infinity", andpropagate_attributesrejected non-string metadata values instead of coercing them.serializer.py: one-line fix to return"-Infinity"whenmath.isinf(obj)is true andobj < 0.propagation.py: widens themetadataparameter type toDict[str, Any]and addsstr(value)coercion for non-string values;Nonevalues are now silently skipped rather than propagated.test_float_special_valuescovers all three float special values; a new propagation test verifiesint/float/boolcoercion; test-data fixture classes renamed fromTest*toMock*to avoid unintentional pytest collection.Confidence Score: 4/5
Safe to merge — the serializer fix is a minimal one-liner with a clear test, and the propagation coercion change is well-covered by the new test.
Both fixes are small and targeted. The only gap is the docstring for
propagate_attributeswhich still tells callers that non-string metadata values are dropped, when they are now silently coerced viastr(). A caller relying on the old drop-with-warning behaviour could be surprised.langfuse/_client/propagation.py — the docstring for the
metadataparameter needs to reflect the new coercion behaviour.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[EventSerializer.default called with float] --> B{math.isnan?} B -- yes --> C[return 'NaN'] B -- no --> D{math.isinf?} D -- no --> E[normal float path] D -- yes --> F{obj < 0?} F -- yes --> G[return '-Infinity'] F -- no --> H[return 'Infinity'] I[propagate_attributes metadata dict] --> J{value is None?} J -- yes --> K[skip / continue] J -- no --> L{isinstance str?} L -- yes --> M[use as-is] L -- no --> N[str coerce via str value] M --> O[_validate_string_value] N --> O O -- valid --> P[add to validated_metadata] O -- invalid --> Q[drop with warning]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix: serialize negative infinity as -Inf..." | Re-trigger Greptile