Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@
before_send_metric: "Optional[Callable[[Metric, Hint], Optional[Metric]]]" = None,
org_id: "Optional[str]" = None,
strict_trace_continuation: bool = False,
stream_gen_ai_spans: bool = False,
stream_gen_ai_spans: bool = True,

Check warning on line 1331 in sentry_sdk/consts.py

View check run for this annotation

@sentry/warden / warden: find-bugs

Blob content (e.g. base64 images) no longer redacted from gen_ai spans when stream_gen_ai_spans defaults to True

This branch makes `stream_gen_ai_spans` opt-out (default `True`) via `should_truncate_gen_ai_input` in `tracing_utils.py`. With the new default, `should_truncate_gen_ai_input` returns `False`, so integrations use the raw normalized messages instead of routing them through `truncate_and_annotate_messages`. Because `redact_blob_message_parts` is only invoked inside `truncate_and_annotate_messages`/`truncate_and_annotate_embedding_inputs`, the unconditional blob redaction (replacing base64 image/blob content with `[Filtered]`) is now bypassed on the default code path. There is no equivalent redaction in the streaming (`traces.py`) path, so multi-modal prompt blobs are sent unredacted to Sentry whenever prompt capture is enabled (`send_default_pii=True` and `include_prompts=True`). This redaction was previously unconditional (applied even with PII enabled), so coupling it to the now-disabled truncation appears to be an unintended side effect.
Comment thread
alexander-alderman-webb marked this conversation as resolved.
Comment thread
alexander-alderman-webb marked this conversation as resolved.
) -> None:
"""Initialize the Sentry SDK with the given parameters. All parameters described here can be used in a call to `sentry_sdk.init()`.
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ def finish(

finished_spans = []
has_gen_ai_span = False
if client.options.get("stream_gen_ai_spans", False):
if client.options.get("stream_gen_ai_spans", True):
for span in self._span_recorder.spans:
if span.timestamp is None:
continue
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/tracing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def should_truncate_gen_ai_input(options: "Optional[dict[str, Any]]") -> bool:
return True

return not options.get(
"stream_gen_ai_spans", False
"stream_gen_ai_spans", True
) and not has_span_streaming_enabled(options)


Expand Down
4 changes: 4 additions & 0 deletions tests/integrations/google_genai/test_google_genai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,7 @@ def test_google_genai_message_truncation(
integrations=[GoogleGenAIIntegration(include_prompts=True)],
traces_sample_rate=1.0,
send_default_pii=True,
stream_gen_ai_spans=False,
)
events = capture_events()

Expand Down Expand Up @@ -2672,6 +2673,7 @@ def test_generate_content_with_function_response(
integrations=[GoogleGenAIIntegration(include_prompts=True)],
traces_sample_rate=1.0,
send_default_pii=True,
stream_gen_ai_spans=False,
)
events = capture_events()

Expand Down Expand Up @@ -2727,6 +2729,7 @@ def test_generate_content_with_mixed_string_and_content(
integrations=[GoogleGenAIIntegration(include_prompts=True)],
traces_sample_rate=1.0,
send_default_pii=True,
stream_gen_ai_spans=False,
)
events = capture_events()

Expand Down Expand Up @@ -2837,6 +2840,7 @@ def test_generate_content_with_list_of_dicts(
integrations=[GoogleGenAIIntegration(include_prompts=True)],
traces_sample_rate=1.0,
send_default_pii=True,
stream_gen_ai_spans=False,
)
events = capture_events()

Expand Down
Loading