Skip to content

.

1f6149e
Select commit
Loading
Failed to load commit list.
Draft

ref(openai): Move input handling code into API-specific functions #5687

.
1f6149e
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Mar 18, 2026 in 8m 33s

4 issues

High

Embeddings function incorrectly sets operation name to 'responses' instead of 'embeddings' - `sentry_sdk/integrations/openai.py:489`

In _set_embeddings_input_data, when PII is disabled or prompts are excluded, the operation name is incorrectly set to 'responses' (line 489) instead of 'embeddings'. This was likely a copy-paste error from _set_responses_api_input_data. This will result in incorrect telemetry data being reported for embedding operations.

Also found at:

  • sentry_sdk/integrations/openai.py:393

Medium

Unreachable code due to duplicate early return - `sentry_sdk/integrations/openai.py:396-402`

In _set_completions_api_input_data, the condition at lines 396-400 checks not should_send_default_pii() or not integration.include_prompts or messages is None, but the first two conditions are already checked and return early at lines 392-394. This makes the first two conditions in the second check unreachable. If messages is None was intended to be checked, it should be a separate check for just messages is None.

Completions API sets incorrect operation name 'responses' instead of 'chat' - `sentry_sdk/integrations/openai.py:393`

In _set_completions_api_input_data, when PII is not enabled or prompts are not included, the span's operation name is incorrectly set to 'responses' instead of 'chat'. This causes incorrect telemetry data, as the completions API operations will be mislabeled as responses API operations.

Also found at:

  • sentry_sdk/integrations/openai.py:489-490

Low

Redundant duplicate conditions create dead code in _set_completions_api_input_data - `sentry_sdk/integrations/openai.py:396-402`

Lines 396-402 check not should_send_default_pii() or not integration.include_prompts again immediately after lines 392-394 already checked the same conditions and returned. The first two conditions in the second check are unreachable dead code. Only messages is None can trigger this block.

Also found at:

  • sentry_sdk/integrations/openai.py:492-499
4 skills analyzed
Skill Findings Duration Cost
code-review 2 5m 28s $1.59
find-bugs 2 8m 20s $3.71
skill-scanner 0 6m 6s $1.24
security-review 0 2m 26s $1.20

Duration: 22m 21s · Tokens: 3.5M in / 49.0k out · Cost: $7.78 (+extraction: $0.03, +merge: $0.00, +fix_gate: $0.01, +dedup: $0.00)