-
Notifications
You must be signed in to change notification settings - Fork 253
feat(api): update API spec from langfuse/langfuse a6c38c6 #1574
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 is declared as a required field () with no default value, meaning any older self-hosted Langfuse server that does not yet return this field in API responses will cause Pydantic to raise a , crashing and . Fix by changing to to match the server-side default and maintain backward compatibility.
Extended reasoning...
The Bug
at line 43 declares — a required Pydantic field with no default. Pydantic v2 raises a if a required field is absent from the parsed data. There is no mechanism in or the setting that compensates for missing required fields — only permits unexpected extra keys, not absent required ones.
Code Path That Triggers It
Both and ultimately call in . If the JSON response from the server lacks the key, this call raises .
Why Existing Code Does Not Prevent It
The setting is insufficient. means Pydantic tolerates extra keys beyond what the model declares — it does not provide defaults for absent declared fields. does not override or validators to fill in missing required fields. The only way to make a Pydantic field tolerant of absence is a Python-level default (, , etc.).
Impact
The Langfuse Python SDK is used against both langfuse.com (cloud) and self-hosted instances. Self-hosted users on older server versions — those deployed before the feature was added — will receive API responses without the key. Every call to list or upsert blob storage integrations will crash with an unhandled . This is a hard failure for anyone running an older self-hosted Langfuse server with a newer SDK.
Addressing the Refutation
The refutation argues this is auto-generated from an API spec where the server contract guarantees will always be present. This holds for the current server version, but Langfuse is self-hostable and users frequently run older instances. A new SDK talking to an older server is a completely normal scenario. The SDK own established pattern — used for , , , , and — is to give defaults to fields added over time. The same principle applies here. Furthermore, and were always part of the API; is genuinely new and will be absent from older server responses.
Step-by-Step Proof
Fix: Change to in . This matches the server-side default and is consistent with how other recently-added fields in the same model are handled.