chore: ensure backwards compatibility for old server versions#1528
Open
marliessophie wants to merge 4 commits intomainfrom
Open
chore: ensure backwards compatibility for old server versions#1528marliessophie wants to merge 4 commits intomainfrom
marliessophie wants to merge 4 commits intomainfrom
Conversation
Contributor
|
@marliessophie Adding a field such as |
Member
Author
I don't believe so, no. We enforce the zod validation for POST /dataset-run-items as strict. We apply the same logic to most API routes. Therefore, if the |
…old server versions" This reverts commit f7eb55c.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Important
Adds backward compatibility for older server versions by retrying dataset run item creation without
datasetVersionif unrecognized, with logging enhancements._is_unrecognized_field_error()inclient.pyto check for unrecognized fields in API errors._process_experiment_item(), retries dataset run item creation withoutdatasetVersionif unrecognized by server.datasetVersionis unrecognized and retries without it.This description was created by
for f7eb55c. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Summary
This PR adds backward compatibility for the
datasetVersionfield in the experiment runner. When the SDK sends aCreateDatasetRunItemRequestwithdatasetVersionto an older Langfuse server that doesn't recognize the field, the client now catches the "unrecognized field" error and retries the request withoutdatasetVersion._is_unrecognized_field_error()that inspects the API error body to detect unrecognized field errorsdatasetVersionif the server doesn't support itdatasetVersionerrors remains unchanged (logged and execution continues)Confidence Score: 4/5
langfuse/_client/client.py.Important Files Changed
datasetVersionfield in dataset run item creation; new helper_is_unrecognized_field_errordefensively parses API error bodies. No bugs found, one optimization opportunity.Sequence Diagram
sequenceDiagram participant ER as Experiment Runner participant API as Langfuse API (old server) ER->>API: Create dataset run item (with datasetVersion) API-->>ER: 400 Error: unrecognized field "datasetVersion" Note over ER: _is_unrecognized_field_error() returns True ER->>API: Retry: Create dataset run item (without datasetVersion) API-->>ER: 200 OK (DatasetRunItem)Last reviewed commit: f7eb55c