| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
|
Gentle ping |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What does this PR do?
Fixes langfuse/langfuse#14615
create_score() catches a pydantic ValidationError inside the broad except Exception block when name or value is None. The error gets logged at ERROR level but the function still returns None, so the caller has no way to tell the score wasn't created.
This catches ValidationError separately and re-raises it as ValueError so the failure is visible at the call site.
Type of change
Verification
List the main commands you ran:
Full unit suite passes aside from 3 pre-existing failures unrelated to this change (Windows path separator issue in test_serializer.py::test_path, flaky atexit tests under parallel execution in test_prompt_atexit.py). Confirmed these fail identically on main before this change too.
Checklist
Greptile Summary
This PR fixes a silent failure in create_score() where passing None for name or value caused a pydantic ValidationError to be caught by the broad except Exception block, logged, and then swallowed — leaving the caller with no indication the score was never created. The fix intercepts ValidationError before the catch-all and re-raises it as ValueError.
Confidence Score: 4/5
Safe to merge; the core fix is correct and well-tested, with one minor behavioral gap when tracing is disabled.
The fix correctly intercepts pydantic ValidationError before the broad except Exception swallows it, and the import is properly placed at module scope. The one gap is that the early-return guard on _tracing_enabled means invalid inputs are not validated at all when tracing is off, so the same None call would raise in a production environment but silently succeed in a tracing-disabled test or staging environment.
The early-return at lines 1917–1918 of langfuse/_client/client.py is worth a second look — consider whether argument validation should be hoisted above it.
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[create_score called] --> B{_tracing_enabled?} B -- No --> C[return None\nno validation] B -- Yes --> D[ScoreBody pydantic constructor] D -- ValidationError\ne.g. name=None --> E[NEW: except ValidationError] E --> F[raise ValueError\nInvalid score parameters] D -- success --> G[build event dict] G --> H[add_score_task] H -- Exception --> I[log error, swallow] H -- success --> J[score enqueued]%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[create_score called] --> B{_tracing_enabled?} B -- No --> C[return None\nno validation] B -- Yes --> D[ScoreBody pydantic constructor] D -- ValidationError\ne.g. name=None --> E[NEW: except ValidationError] E --> F[raise ValueError\nInvalid score parameters] D -- success --> G[build event dict] G --> H[add_score_task] H -- Exception --> I[log error, swallow] H -- success --> J[score enqueued]Reviews (1): Last reviewed commit: "fix(score): raise ValueError when create..." | Re-trigger Greptile