Skip to content

Span data is always be a primitive data type #4643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 30, 2025

Conversation

antonpirker
Copy link
Member

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.

@antonpirker antonpirker requested a review from a team as a code owner July 30, 2025 09:29
cursor[bot]

This comment was marked as outdated.

if isinstance(normalized, (int, float, bool, str)):
span.set_data(key, normalized)
else:
span.set_data(key, str(normalized))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

assert (
"{'role': 'user', 'content': 'hello'}"
in span["data"][SPANDATA.AI_INPUT_MESSAGES]
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Copy link

codecov bot commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.75%. Comparing base (c273f67) to head (f668921).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

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     
Files with missing lines Coverage Δ
sentry_sdk/ai/utils.py 66.66% <100.00%> (+3.03%) ⬆️

... and 1 file with indirect coverage changes

@antonpirker antonpirker merged commit 38b570a into master Jul 30, 2025
138 checks passed
@antonpirker antonpirker deleted the antonpriker/llm-input-putput-text branch July 30, 2025 10:35
@antonpirker antonpirker restored the antonpriker/llm-input-putput-text branch July 30, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants