Skip to content

fix(core): Fix OpenAI SDK private field access by binding non-instrumented fns #17163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025

Conversation

RulaKhaled
Copy link
Member

The OpenAI SDK v5 uses ES private class fields (e.g. #baseURL), which can only be accessed when methods are called with the correct this context. In our instrumentation, methods that are not explicitly instrumented (i.e. skipped by shouldInstrument) were returned unbound, which broke calls to internal OpenAI methods like .parse() by triggering:
TypeError: Cannot read private member from an object whose class did not declare it.

This PR fixes that by explicitly binding all non-instrumented functions to their original instance (value.bind(obj)), ensuring correct this context and avoiding runtime errors when accessing private fields.

@RulaKhaled RulaKhaled changed the title fix(core): Fix OpenAI SDK private field access by binding non-instrum… fix(core): Fix OpenAI SDK private field access by binding non-instrumented fns Jul 24, 2025
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch & tests!

@RulaKhaled RulaKhaled merged commit 8b2c685 into develop Jul 25, 2025
176 checks passed
@RulaKhaled RulaKhaled deleted the fix-openai-integration-err branch July 25, 2025 06:47
@RulaKhaled RulaKhaled restored the fix-openai-integration-err branch July 25, 2025 07:08
RulaKhaled added a commit that referenced this pull request Jul 25, 2025
…ented fns (#17163)

The OpenAI SDK v5 uses ES private class fields (e.g. #baseURL), which
can only be accessed when methods are called with the correct this
context. In our instrumentation, methods that are not explicitly
instrumented (i.e. skipped by shouldInstrument) were returned unbound,
which broke calls to internal OpenAI methods like .parse() by
triggering:
TypeError: Cannot read private member from an object whose class did not
declare it.

This PR fixes that by explicitly binding all non-instrumented functions
to their original instance (value.bind(obj)), ensuring correct this
context and avoiding runtime errors when accessing private fields.

(cherry picked from commit 8b2c685)
RulaKhaled added a commit that referenced this pull request Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAI integration is breaking openai calls, even when the integration isn't enabled
2 participants