From 936064e729efc990d0348d4d8748d17054f3bb67 Mon Sep 17 00:00:00 2001 From: Fabian Schindler Date: Thu, 27 Nov 2025 14:54:22 +0100 Subject: [PATCH 1/2] fix(integrations): do not exit early when config is not passed as it is not required and prohibits setting `gen_ai.request.messages` --- sentry_sdk/integrations/google_genai/utils.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sentry_sdk/integrations/google_genai/utils.py b/sentry_sdk/integrations/google_genai/utils.py index 0507b4fa00..0b274eade7 100644 --- a/sentry_sdk/integrations/google_genai/utils.py +++ b/sentry_sdk/integrations/google_genai/utils.py @@ -442,19 +442,14 @@ def set_span_data_for_request(span, integration, model, contents, kwargs): if kwargs.get("stream", False): span.set_data(SPANDATA.GEN_AI_RESPONSE_STREAMING, True) - config = kwargs.get("config") - - if config is None: - return - - config = cast(GenerateContentConfig, config) + config = kwargs.get("config") # type: Optional[GenerateContentConfig] # Set input messages/prompts if PII is allowed if should_send_default_pii() and integration.include_prompts: messages = [] # Add system instruction if present - if hasattr(config, "system_instruction"): + if config and hasattr(config, "system_instruction"): system_instruction = config.system_instruction if system_instruction: system_text = extract_contents_text(system_instruction) From b8ecd5d445606f2de3f7cc434c28b01ff82a075a Mon Sep 17 00:00:00 2001 From: Fabian Schindler Date: Mon, 1 Dec 2025 09:22:30 +0100 Subject: [PATCH 2/2] fix(integrations): mypy typing issue --- sentry_sdk/integrations/google_genai/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/google_genai/utils.py b/sentry_sdk/integrations/google_genai/utils.py index 0b274eade7..bda5822bb4 100644 --- a/sentry_sdk/integrations/google_genai/utils.py +++ b/sentry_sdk/integrations/google_genai/utils.py @@ -491,7 +491,7 @@ def set_span_data_for_request(span, integration, model, contents, kwargs): span.set_data(span_key, value) # Set tools if available - if hasattr(config, "tools"): + if config is not None and hasattr(config, "tools"): tools = config.tools if tools: formatted_tools = _format_tools_for_span(tools)