Span data is always be a primitive data type#4643
Conversation
| if isinstance(normalized, (int, float, bool, str)): | ||
| span.set_data(key, normalized) | ||
| else: | ||
| span.set_data(key, str(normalized)) |
There was a problem hiding this comment.
Bug: Unexpected Stringification of None and Non-Collection Types
The isinstance check for primitive types (int, float, bool, str) excludes None, causing None values to be stringified to "None". This is unexpected, as None is typically preserved as a primitive/null value. More broadly, this logic stringifies any non-primitive type, which may be overly broad if the intent was to only stringify collections (lists, tuples, dicts).
Locations (1)
| assert ( | ||
| "{'role': 'user', 'content': 'hello'}" | ||
| in span["data"][SPANDATA.AI_INPUT_MESSAGES] | ||
| ) |
There was a problem hiding this comment.
Bug: Test Assertions Fail Due to Unstable Dictionary String Representation
The test assertions now depend on exact string representations of dictionaries (e.g., "{'role': 'system', 'content': 'some context'}"). This is brittle because dictionary string representation can vary between Python versions and the order of keys is not guaranteed, making tests prone to false failures even if the underlying functionality is correct.
Locations (2)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4643 +/- ##
==========================================
+ Coverage 80.74% 80.75% +0.01%
==========================================
Files 156 156
Lines 16630 16632 +2
Branches 2830 2831 +1
==========================================
+ Hits 13428 13432 +4
+ Misses 2312 2311 -1
+ Partials 890 889 -1
|
The AI Agent insights module excepts the data not to be lists, tuples, or dicts. Make sure that we always send a string in this case.