Skip to content

bug(sdk-python): create_score silently swallows ValidationError when name or value is None #14615

Description

@RudraDudhat2509

Describe the bug

I was going through the codebase and noticed that create_score catches a pydantic.ValidationError inside the broad except Exception block when name or value is None. The error gets logged internally but the function still returns None, so the caller has no way to detect the failure programmatically.

Steps to reproduce

import os, logging
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-test"
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-test"
os.environ["LANGFUSE_HOST"] = "http://localhost:19999"

from langfuse import Langfuse
lf = Langfuse()

result = lf.create_score(name="accuracy", value=None, trace_id="some-trace-id")
print(result)  # None, score silently dropped, no exception raised

The ValidationError does appear in langfuse logs at ERROR level, but if logs are routed away or suppressed (which is common in production), this is completely invisible to the caller.

Expected behavior

A ValueError should be raised at the call site when name or value is None. Network failures make sense to swallow since a server being down is expected, but passing the wrong type for a required field is a programmer mistake and should fail loudly. Other observability SDKs raise on this kind of thing rather than swallowing it.

I have a fix ready if this looks good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions