Skip to content

fix: Remove unpack parameter from set_data_normalized() - #8149

Draft
alexander-alderman-webb wants to merge 1 commit into
masterfrom
webb/anthropic-format
Draft

alexander-alderman-webb wants to merge 1 commit into
masterfrom
webb/anthropic-format

Conversation

@alexander-alderman-webb

Copy link
Copy Markdown
Collaborator

Description

Issues

Reminders

@alexander-alderman-webb alexander-alderman-webb changed the title fix: Remove unpack parameter from set_data_normalized() fix: Remove unpack parameter from set_data_normalized() Oct 29, 2026
Comment thread sentry_sdk/ai/utils.py
Comment on lines 480 to +494
@@ -492,9 +490,8 @@ def set_data_normalized(
span: "Union[Span, StreamedSpan]",
key: str,
value: "Any",
unpack: bool = True,
) -> None:
normalized = _normalize_data(value, unpack=unpack)
normalized = _normalize_data(value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Singleton AI response lists are now emitted as JSON arrays

set_data_normalized() now preserves list values, then JSON-serializes them as arrays. Several integrations pass text outputs as lists even when there is only one text block, so a span that previously exposed "Hi, I'm Claude." now exposes ["Hi, I'm Claude."]. This changes the shape of the emitted span attribute and conflicts with existing tests and consumers expecting a scalar. Flatten scalar-semantic outputs at those call sites, or update the tests and document the new attribute shape if this is intentional.

Evidence
  • _normalize_data() preserves lists, and set_data_normalized() JSON-serializes non-scalars; a one-item list therefore remains a JSON array string.
  • anthropic._set_output_data() collects text blocks in output_messages["response"] and passes that list to set_data_normalized().
  • The Anthropic tests still assert a bare "Hi, I'm Claude." value for these responses, confirming the emitted shape no longer matches the existing expectation.
  • LangChain also passes nested generation text lists to set_data_normalized(), so singleton generation results are affected as well.

Identified by Warden · code-review · 8XB-P9Q

This branch has not been deployed

No deployments
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.

1 participant