Repository navigation
feat(api): update API spec from langfuse/langfuse 1744e30 - #1963
langfuse-bot wants to merge 1 commit into
Conversation
|
@claude review |
There was a problem hiding this comment.
Claude Code Review
No review was started: this request came from a bot account. Manual reviews can only be requested by someone with write access to this repository. Ask a maintainer to comment @claude review, or have your automation post the comment from a user account with write access.
Tip: disable this comment in your organization's Code Review settings.
| data_type: typing.Optional[ScoreDataType] = OMIT, | ||
| config_id: typing.Optional[str] = OMIT, | ||
| source: typing.Optional[CreateScoreSource] = OMIT, | ||
| request: CreateScoresRequest, |
There was a problem hiding this comment.
ScoresClient.create now requires request, but ScoreV1Client.create still passes name, value, and the other old keywords. Calling client.legacy.score_v1.create(name="quality", value=0.9) now raises TypeError before sending a score. The async alias breaks the same way.
Update both compatibility methods and their generator to build CreateScoreRequest and pass request=....
Prompt To Fix With AI
This is a comment left during a code review.
Path: langfuse/api/scores/client.py
Line: 39
Comment:
**Legacy scores stop saving**
`ScoresClient.create` now requires `request`, but `ScoreV1Client.create` still passes `name`, `value`, and the other old keywords. Calling `client.legacy.score_v1.create(name="quality", value=0.9)` now raises `TypeError` before sending a score. The async alias breaks the same way.
Update both compatibility methods and their generator to build `CreateScoreRequest` and pass `request=...`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| Examples | ||
| -------- | ||
| from langfuse import LangfuseAPI | ||
| from langfuse.scores import CreateScoreRequest |
There was a problem hiding this comment.
The new examples import CreateScoreRequest from langfuse.scores, but that package does not exist. The model lives under langfuse.api.scores. The skills examples make the same mistake with langfuse.unstable.skills, and the batch example also uses nonexistent package paths.
Use the actual langfuse.api paths so users can run these examples without import errors.
Prompt To Fix With AI
This is a comment left during a code review.
Path: langfuse/api/scores/client.py
Line: 59
Comment:
**New examples cannot run**
The new examples import `CreateScoreRequest` from `langfuse.scores`, but that package does not exist. The model lives under `langfuse.api.scores`. The skills examples make the same mistake with `langfuse.unstable.skills`, and the batch example also uses nonexistent package paths.
Use the actual `langfuse.api` paths so users can run these examples without import errors.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| Parameters | ||
| ---------- | ||
| sha256hashes : str | ||
| Comma-separated list of one to 50 canonical base64-encoded SHA-256 hashes from skill file manifests. URL-encode the value, including +, /, and = characters. |
There was a problem hiding this comment.
Hash instructions encode twice
get_file_contents tells callers to URL-encode sha256hashes, but HTTPX already encodes query parameters. Following this instruction turns a hash ending in = into a value ending in %3D after the server reads the query, so the hash no longer matches.
Remove the manual encoding instruction and tell callers to pass the raw comma-separated hashes.
Prompt To Fix With AI
This is a comment left during a code review.
Path: langfuse/api/unstable/skills/client.py
Line: 262
Comment:
**Hash instructions encode twice**
`get_file_contents` tells callers to URL-encode `sha256hashes`, but HTTPX already encodes query parameters. Following this instruction turns a hash ending in `=` into a value ending in `%3D` after the server reads the query, so the hash no longer matches.
Remove the manual encoding instruction and tell callers to pass the raw comma-separated hashes.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
|
||
| This endpoint implements the OTLP/HTTP specification for trace ingestion, providing native OpenTelemetry integration for Langfuse Observability. | ||
|
|
||
| Together with Observations API v2 and Metrics API v2, this is the only real-time write path. Other public API endpoints can delay data by about 10 minutes. Direct exporters must send `x-langfuse-ingestion-version: 4`; current Python and JS SDKs already do. |
There was a problem hiding this comment.
The new text says the current Python SDK already sends x-langfuse-ingestion-version: 4, but its default exporter does not set that header. It sends only authentication and SDK details unless the caller supplies additional headers.
Correct this claim or add the promised header so users can rely on this guidance to enable real-time writes.
Prompt To Fix With AI
This is a comment left during a code review.
Path: langfuse/api/opentelemetry/client.py
Line: 41
Comment:
**SDK header claim is wrong**
The new text says the current Python SDK already sends `x-langfuse-ingestion-version: 4`, but its default exporter does not set that header. It sends only authentication and SDK details unless the caller supplies additional headers.
Correct this claim or add the promised header so users can rely on this guidance to enable real-time writes.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
I checked one more thing beyond the inline findings: whether any SDK code outside langfuse/api/ uses the removed sdk-log types or BlobStorageIntegrationType.visit(). Nothing does, so removing those types and adding the new required google_cloud_storage callback doesn't break any internal callers.
Extended reasoning...
This is a regenerated Fern client under langfuse/api/ (62 files), and it touches no auth or security-sensitive SDK logic. A repo-wide search outside langfuse/api found no references to SdkLog, sdk_log, BlobStorageIntegrationType or .visit(), so those breaking changes don't affect internal callers.
| def create( | ||
| self, | ||
| *, | ||
| name: str, | ||
| value: CreateScoreValue, | ||
| id: typing.Optional[str] = OMIT, | ||
| trace_id: typing.Optional[str] = OMIT, | ||
| session_id: typing.Optional[str] = OMIT, | ||
| observation_id: typing.Optional[str] = OMIT, | ||
| dataset_run_id: typing.Optional[str] = OMIT, | ||
| comment: typing.Optional[str] = OMIT, | ||
| metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, | ||
| environment: typing.Optional[str] = OMIT, | ||
| queue_id: typing.Optional[str] = OMIT, | ||
| data_type: typing.Optional[ScoreDataType] = OMIT, | ||
| config_id: typing.Optional[str] = OMIT, | ||
| source: typing.Optional[CreateScoreSource] = OMIT, | ||
| request: CreateScoresRequest, | ||
| request_options: typing.Optional[RequestOptions] = None, |
There was a problem hiding this comment.
🔴 After this merge, every caller of the deprecated client.legacy.score_v1.create(name=..., value=...) gets a TypeError instead of a created score. The legacy alias forwards name=, value=, trace_id= and similar keywords to CanonicalScoresClient.create. That method now accepts only request: CreateScoresRequest and request_options. Fix: make both legacy aliases build CreateScoreRequest(...) and call .create(request=..., ...), then unwrap CreateScoresResponse. Apply the same change to the templates in scripts/patch_generated_score_compat.py, which covers the 4 sites listed. Sites: legacy/score_v1/client.py:54, :147; patch_generated_score_compat.py:49, :92.
Why this was flagged
A user calls client.legacy.score_v1.create(name="quality", value=0.9) or the async variant. langfuse/api/legacy/score_v1/client.py:54-72 and :147-165 pass 14 keyword arguments to ScoresClient.create. After this diff, langfuse/api/scores/client.py:36-40 (and the async one at :285) only takes request and request_options. Python raises TypeError: create() got an unexpected keyword argument 'name'. On the base branch the canonical method took those keywords, so the compat alias worked. The fail-closed postprocessor gives no protection. patch_generated_api (scripts/patch_generated_score_compat.py:197-199) only checks that the strings def create( and the alias marker are present, then returns False with "No patch needed.". Its kwargs body (lines 49-67 and 92-110) has the same mismatch. tests/unit/test_patch_generated_score_compat.py:113 uses a fake create(**kwargs), so CI does not catch it.
Verification: After this diff, langfuse/api/scores/client.py:36-41 is def create(self, *, request: CreateScoresRequest, request_options=None) -> CreateScoresResponse. So the forwarded name= keyword raises TypeError: create() got an unexpected keyword argument 'name'. The post-generation script scripts/patch_generated_score_compat.py does not catch this.
| data_type: typing.Optional[ScoreDataType] = OMIT, | ||
| config_id: typing.Optional[str] = OMIT, | ||
| source: typing.Optional[CreateScoreSource] = OMIT, | ||
| request: CreateScoresRequest, |
There was a problem hiding this comment.
🔴 Users who already moved to api.scores.create(name=..., value=...) get a TypeError after this merge, with no deprecation period. The canonical sync and async create (client.py:39 and :288) now accept only request: CreateScoresRequest, so every keyword call fails. The repo's own deprecation text sent users to this method. Fix: keep a keyword-accepting path on the canonical scores.create, for example by having the post-generation compat script wrap the keywords into a CreateScoreRequest. Updating only the legacy score_v1 alias would not cover callers of api.scores.create itself.
Why this was flagged
The trigger is user code calling langfuse.api.scores.create(name="quality", value=0.9, trace_id=...) or await langfuse.async_api.scores.create(...). On the base, ScoresClient.create took name, value, trace_id and 11 other keyword arguments. It now takes only request (langfuse/api/scores/client.py:39, async at :288; raw_client.py has the same change), so Python raises TypeError: create() got an unexpected keyword argument 'name' before any request is sent. These are the callers that followed the alias docstring in scripts/patch_generated_score_compat.py:48 and :91, "Deprecated compatibility alias. Use client.scores.create". The filed findings only cover legacy.score_v1.create forwarding. Repairing that alias, for example by building a CreateScoreRequest inside it, still leaves direct callers of scores.create broken. scripts/patch_generated_score_compat.py only checks that a def create( exists (line 188), not its signature, so it does not catch this break. No in-repo SDK code calls scores.create, so only external users are hit.
Verification: Trigger: any existing user code that calls langfuse.api.scores.create(name=..., value=..., ...) with keyword arguments, which was the only signature on the base. In langfuse/api/scores/client.py around line 36, create now takes only request: CreateScoresRequest. A call like create(name="quality", value=0.9) raises TypeError. The compat script only patches legacy.score_v1.
Fix the legacy score creation alias before merging; it now fails before sending any score.
Summary
Updates the generated API with batch scores, unstable skills, Google Cloud Storage, API-key names and expiry dates, prompt filters, and revised ingestion guidance.
Reviews (1) · Last reviewed commit: "feat(api): update API spec from langfuse..." · Reviewed by Greptile