Skip to content

fix(api): preserve score create compatibility - #888

Merged
hassiebp merged 1 commit into
mainfrom
hassiebbot/lfe-10397-score-create-alias
Jul 29, 2026
Merged

fix(api): preserve score create compatibility#888
hassiebp merged 1 commit into
mainfrom
hassiebbot/lfe-10397-score-create-alias

Conversation

@hassiebp

@hassiebp hassiebp commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • expose client.scores.create() immediately while the Fern operation is promoted out of legacy
  • preserve client.legacy.scoreV1.create() as a deprecated delegating alias after regeneration
  • preserve the legacy request, response, and source type exports
  • fail closed when future Fern output no longer matches the expected score clients

Coordination

The postprocessor was also exercised against the exact TypeScript output generated from the coordinated Fern change. After the existing generated-auth patch and formatting, the future @langfuse/core declaration build and the two-path request test pass.

Impacted packages

  • @langfuse/core

Verification

  • pnpm buildTasks: 8 successful, 8 total
  • pnpm exec vitest run "tests/unit/score-create-api.test.ts" --project=unitTests 2 passed (2)
  • pnpm lint — passed
  • pnpm typecheck — passed
  • pnpm format:check — passed
  • commit hook pnpm precommit:checkTasks: 3 successful, 3 total

Greptile Summary

Adds a compatibility layer for score creation.

  • Exposes client.scores.create() by delegating to the existing legacy score client.
  • Adds a postprocessor that can preserve either the canonical or deprecated API path across future Fern regeneration.
  • Preserves legacy score type exports and adds request-path compatibility tests.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The new canonical method preserves the existing request implementation through delegation, while the postprocessor explicitly validates generated-client states and the tests cover both public access paths.

Reviews (1): Last reviewed commit: "fix(api): preserve score create compatib..." | Re-trigger Greptile

Context used:

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
langfuse-js Ready Ready Preview Jul 28, 2026 11:47am

Request Review

@github-actions

Copy link
Copy Markdown

@claude review

@hassiebp
hassiebp merged commit aa8012c into main Jul 29, 2026
18 checks passed
@hassiebp
hassiebp deleted the hassiebbot/lfe-10397-score-create-alias branch July 29, 2026 12:09

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — verified locally (tests pass, script parses cleanly).

What was reviewed:

  • The new Scores.create() delegation to ScoreV1 in the generated client, and confirmed the legacy CreateScoreRequest/CreateScoreResponse/CreateScoreSource types are still exported and re-exported correctly.
  • The postprocessor script's fail-closed logic (throws on ambiguous or missing create() on both clients) rather than silently guessing — ran it as valid JS and traced through the four branch cases.
  • Ran tests/unit/score-create-api.test.ts locally; both the canonical and legacy request paths post to /api/public/scores with the same body.
Extended reasoning...

Overview

This PR is a targeted compatibility shim for the generated Langfuse API client (@langfuse/core). It (1) manually adds a create() method to Scores in the currently-checked-in generated Client.ts that delegates to the legacy ScoreV1.create(), and (2) adds a new postprocessor script (scripts/patch-generated-score-create-alias.mjs) intended to be invoked by a future Fern code-generation workflow (coordinated with a companion PR in langfuse/langfuse) once the create operation is promoted out of legacy in the API spec. A new unit test exercises both the canonical (client.scores.create) and legacy (client.legacy.scoreV1.create) code paths against a stubbed fetch.

Security risks

None identified. This only affects client-side request construction/dispatch for an already-public API operation (score creation); no auth, crypto, or permission logic is touched. The delegation just forwards the same request/options to the underlying HTTP call.

Level of scrutiny

Moderate-low is appropriate: this is generated/scaffolding code with a narrow, mechanical purpose (keep both API surface names working across a coordinated spec migration), not application logic. The postprocessor script itself isn't wired into this repo's build/CI yet (its invocation lives in the coordinated core Fern PR's generation workflow), so its blast radius today is limited to being unused until that companion change lands — it is effectively documentation-as-code for the next regeneration. I verified it parses and its guard logic (unique-anchor matching, throwing on ambiguous/missing create()) fails closed rather than corrupting generated output.

Other factors

Local verification: pnpm install + pnpm exec vitest run tests/unit/score-create-api.test.ts --project=unit passes (2/2), matching the PR's stated verification. Confirmed LangfuseAPI.legacy is exported from the resources index so the delegating type references resolve. No outstanding review comments to address, and no bugs were surfaced by the bug-hunting pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant