Skip to content

fix(core): gracefully handle missing keys #1200

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 2 commits into from
May 28, 2025
Merged

fix(core): gracefully handle missing keys #1200

merged 2 commits into from
May 28, 2025

Conversation

hassiebp
Copy link
Contributor

@hassiebp hassiebp commented May 28, 2025

Important

Reorder initialization in client.py and refactor environment variable handling in observe.py to gracefully handle missing keys.

  • Initialization Order in client.py:
    • Reorder initialization of _host, _environment, _mask, _project_id, and sample_rate to handle missing keys gracefully.
    • Move _tracing_enabled initialization before debug logging setup.
  • Environment Variable Handling in observe.py:
    • Refactor function_io_capture_enabled assignment for readability.

This description was created by Ellipsis for 1fb2d50. You can customize this summary. It will automatically update as commits are pushed.

Greptile Summary

Disclaimer: Experimental PR review

This PR improves error handling and code organization in the Langfuse Python client, focusing on graceful handling of missing API keys and cleaner environment variable checks.

  • Streamlined environment variable check in langfuse/_client/observe.py by consolidating the LANGFUSE_OBSERVE_DECORATOR_IO_CAPTURE_ENABLED logic into a single line
  • Reorganized initialization sequence in langfuse/_client/client.py to set core attributes before API key validation
  • Improved error handling flow by validating API keys after setting essential client properties
  • Removed redundant attribute initializations after key validation in client initialization

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@hassiebp hassiebp merged commit 23650a7 into main May 28, 2025
10 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-5179 branch May 28, 2025 16:35
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.

bug: AttributeError: 'Langfuse' object has no attribute '_environment' and issues with turning langfuse off
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy