Title: OpenAI integration fails when response has no messages in choices. · Issue #5071 · getsentry/sentry-python · GitHub
Open Graph Title: OpenAI integration fails when response has no messages in choices. · Issue #5071 · getsentry/sentry-python
X Title: OpenAI integration fails when response has no messages in choices. · Issue #5071 · getsentry/sentry-python
Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.43.0 Steps to Reproduce I'm using openai lib with gemini. For couple of my tasks gemini's response was like this: { "id": "vOALaYOpG4CJ7M8PlpOM0QY", "choices": [ { "finish_reason":...
Open Graph Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.43.0 Steps to Reproduce I'm using openai lib with gemini. For couple of my tasks gemini's response was like this: { "id": "vOALaYOpG4CJ7M8Pl...
X Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.43.0 Steps to Reproduce I'm using openai lib with gemini. For couple of my tasks gemini's response was like this: { "id": ...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/5071
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OpenAI integration fails when response has no messages in choices.","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n2.43.0\n\n### Steps to Reproduce\n\nI'm using openai lib with gemini. For couple of my tasks gemini's response was like this:\n```json\n{\n \"id\": \"vOALaYOpG4CJ7M8PlpOM0QY\",\n \"choices\": [\n {\n \"finish_reason\": \"content_filter: PROHIBITED_CONTENT\",\n \"index\": 0,\n \"logprobs\": null,\n \"message\": null\n }\n ],\n \"created\": 1762386108,\n \"model\": \"gemini-2.5-flash-lite\",\n \"object\": \"chat.completion\",\n \"service_tier\": null,\n \"system_fingerprint\": null,\n \"usage\": {\n \"completion_tokens\": 0,\n \"prompt_tokens\": 5431,\n \"total_tokens\": 5431,\n \"completion_tokens_details\": null,\n \"prompt_tokens_details\": null\n }\n}\n```\n\nThis made openai integration choke like following:\n```\nFile /usr/local/lib/python3.12/site-packages/sentry_sdk/integrations/openai.py:246, in _set_output_data(span, response, kwargs, integration, finish_span)\n 244 if hasattr(response, \"choices\"):\n 245 if should_send_default_pii() and integration.include_prompts:\n--> 246 response_text = [choice.message.model_dump() for choice in response.choices]\n 247 if len(response_text) > 0:\n 248 set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_TEXT, response_text)\n\nAttributeError: 'NoneType' object has no attribute 'model_dump'\n```\n\nWhich is understandable, as integration clearly expects message to be present.\n\nI'm using latest sdk and openai client (openai==2.7.1)\n\n### Expected Result\n\nIt should ignore such messages or report them separately\n\n### Actual Result\n\nIt dies with a traceback even before I can read the message from openai lib.","author":{"url":"https://github.com/dchaplinsky","@type":"Person","name":"dchaplinsky"},"datePublished":"2025-11-05T23:48:29Z","url":"https://github.com/getsentry/sentry-python/issues/5071"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e694659d-66c7-bf90-73a4-d26fab44042b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D99C:200C95:50D278:6C2265:6B009053 |
| html-safe-nonce | d9bb40b8d523fd043bec93aab48968567bf0eedeb716fa63ed5db3fbe5deb011 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTlDOjIwMEM5NTo1MEQyNzg6NkMyMjY1OjZCMDA5MDUzIiwidmlzaXRvcl9pZCI6IjEzNDM1MTg5NzM3NDM4OTQ2MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f4a65aa0e9066907784d254dd6ade4aadf7dbe649b3e83b2268dd8964bd8084a |
| hovercard-subject-tag | issue:3593244450 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/5071/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a22769df3207e2dc1e9b1c987df954419040a4d04e1ada4a52119caec7d6acfc/getsentry/sentry-python/issues/5071 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a22769df3207e2dc1e9b1c987df954419040a4d04e1ada4a52119caec7d6acfc/getsentry/sentry-python/issues/5071 |
| og:image:alt | How do you use Sentry? Sentry Saas (sentry.io) Version 2.43.0 Steps to Reproduce I'm using openai lib with gemini. For couple of my tasks gemini's response was like this: { "id": "vOALaYOpG4CJ7M8Pl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dchaplinsky |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width