Skip to content

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

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

Backport of #17163

…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 RulaKhaled merged commit fa7a2b0 into v9 Jul 25, 2025
170 of 171 checks passed
@RulaKhaled RulaKhaled deleted the rola/fix-openai-err branch July 25, 2025 07:44
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.

2 participants