Skip to content

Fix set_api_key breaking cached property mechanism #1339

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 4 commits into from
Aug 1, 2025

Conversation

DanielHashmi
Copy link
Contributor

Problem

The BackendSpanExporter.set_api_key() method was directly assigning to self.api_key, which created an instance attribute that permanently shadowed the @cached_property. This broke the environment variable fallback mechanism.

Solution

  • Clear the cached property if it exists before updating the private attribute
  • This preserves the intended fallback behavior to environment variables

Testing

  • Added test to verify environment variable fallback works after calling set_api_key()
  • Existing functionality remains unchanged

@seratch seratch added bug Something isn't working feature:tracing labels Aug 1, 2025
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

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

LGTM; Thank you for sending this!

@seratch seratch merged commit 61e4fb8 into openai:main Aug 1, 2025
7 checks passed
@DanielHashmi DanielHashmi deleted the fix-set-api-key-cached-property branch August 1, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature:tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants