Skip to content

Commit de0263f

Browse files
fix(integrations): do not exit early when config is not passed as it is not required and prohibits setting gen_ai.request.messages (#5167)
#### Issues Closes https://linear.app/getsentry/issue/TET-1454/py-google-genai-request-messages-missing
1 parent 71afdf9 commit de0263f

File tree

1 file changed

+3
-8
lines changed
  • sentry_sdk/integrations/google_genai

1 file changed

+3
-8
lines changed

sentry_sdk/integrations/google_genai/utils.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,14 @@ def set_span_data_for_request(span, integration, model, contents, kwargs):
442442
if kwargs.get("stream", False):
443443
span.set_data(SPANDATA.GEN_AI_RESPONSE_STREAMING, True)
444444

445-
config = kwargs.get("config")
446-
447-
if config is None:
448-
return
449-
450-
config = cast(GenerateContentConfig, config)
445+
config = kwargs.get("config") # type: Optional[GenerateContentConfig]
451446

452447
# Set input messages/prompts if PII is allowed
453448
if should_send_default_pii() and integration.include_prompts:
454449
messages = []
455450

456451
# Add system instruction if present
457-
if hasattr(config, "system_instruction"):
452+
if config and hasattr(config, "system_instruction"):
458453
system_instruction = config.system_instruction
459454
if system_instruction:
460455
system_text = extract_contents_text(system_instruction)
@@ -496,7 +491,7 @@ def set_span_data_for_request(span, integration, model, contents, kwargs):
496491
span.set_data(span_key, value)
497492

498493
# Set tools if available
499-
if hasattr(config, "tools"):
494+
if config is not None and hasattr(config, "tools"):
500495
tools = config.tools
501496
if tools:
502497
formatted_tools = _format_tools_for_span(tools)

0 commit comments

Comments
 (0)