Skip to content

OpenAI integration is breaking openai calls, even when the integration isn't enabled #17159

@marcelgerber

Description

@marcelgerber

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

9.41

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://codesandbox.io/p/devbox/hardcore-margulis-fsy833?file=%2Fpackage.json%3A13%2C23

import * as Sentry from "@sentry/node"

Sentry.init({
  dsn: "https://public@dsn.ingest.sentry.io/1337",
  tracesSampleRate: 0.1,
})


const OpenAI = require("openai").OpenAI;

const openai = new OpenAI({
  apiKey: "fake-openai-api-key",
})
openai.chat.completions.parse({
  messages: [{ role: "user", content: "Test" }],
  model: "gpt-4o",
})

Steps to Reproduce

  1. Go to the Codesandbox
  2. Run pnpm install, if deps are not already installed
  3. Run pnpm tsx main.js

Expected Result

The OpenAI call should just work without issues.

Actual Result

Instead, we get a runtime error:

> pnpm tsx main.js
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
TypeError: Cannot read private member from an object whose class did not declare it
    at Object.__classPrivateFieldGet (/project/workspace/node_modules/.pnpm/openai@5.10.2/node_modules/openai/internal/tslib.js:21:15)
    at Proxy.buildURL (/project/workspace/node_modules/.pnpm/openai@5.10.2/node_modules/openai/src/client.ts:446:23)
    at Proxy.buildRequest (/project/workspace/node_modules/.pnpm/openai@5.10.2/node_modules/openai/src/client.ts:818:22)
    at Proxy.makeRequest (/project/workspace/node_modules/.pnpm/openai@5.10.2/node_modules/openai/src/client.ts:532:46)

Further context

  • @sentry/node version 9.39 works fine, versions 9.40 and 9.41 are both broken
  • There is an issue open for this in the openai repo, because initially I and others believed this to be an issue with the openai package itself: TypeError: Cannot read private member from an object whose class did not declare it at __classPrivateFieldGet openai/openai-node#1590
  • Note that the OpenAI instrumentation isn't even enabled in the above repro example
  • It seems important that the OpenAI package is imported using require, not import. Also, it seems important that tsx is involved in running the project. There are probably also other ways to run into this problem, but I couldn't find any in this small repro environment.
  • It also seems relevant that the code is using the chat.completions.parse endpoint, instead of chat.completions.create.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions