Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions sentry_sdk/integrations/huggingface_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ def new_huggingface_task(*args: "Any", **kwargs: "Any") -> "Any":
span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, response_model)

if finish_reason is not None:
set_data_normalized(
span,
Copy link

Choose a reason for hiding this comment

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

Non-serializable finish reason stored

High Severity

Replacing set_data_normalized with span.set_data for SPANDATA.GEN_AI_RESPONSE_FINISH_REASONS can store non-primitive finish_reason values (e.g., enums/objects/lists) without normalization, which can break span/event serialization or change the expected stored type for gen_ai.response.finish_reasons.

Additional Locations (2)

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

span.set_data(
SPANDATA.GEN_AI_RESPONSE_FINISH_REASONS,
finish_reason,
)
Expand Down Expand Up @@ -258,8 +257,7 @@ def new_details_iterator() -> "Iterable[Any]":
yield chunk

if finish_reason is not None:
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_RESPONSE_FINISH_REASONS,
finish_reason,
)
Expand Down Expand Up @@ -337,8 +335,7 @@ def new_iterator() -> "Iterable[str]":
)

if finish_reason is not None:
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_RESPONSE_FINISH_REASONS,
finish_reason,
)
Expand Down
Loading