🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(scores): accept lowercase source and dataType on v3 list endpoint (#14092)
Niklas Semmler5f43038c136a
diff --git a/fern/apis/server/_drafts/scores-v3.yml b/fern/apis/server/_drafts/scores-v3.ymlindex f3336c8324..282db893db 100644--- a/fern/apis/server/_drafts/scores-v3.yml+++ b/fern/apis/server/_drafts/scores-v3.yml@@ -44,10 +44,10 @@ service:docs: Comma-separated list of score names to filter by.source:type: optional<string>- docs: Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL).+ docs: Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL). Case-insensitive — `api` and `API` are equivalent.dataType:type: optional<string>- docs: Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax.+ docs: Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and `NUMERIC` are equivalent. Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax.environment:type: optional<string>docs: Comma-separated list of environments to filter by.diff --git a/packages/shared/src/features/scores/interfaces/api/v3/endpoints.ts b/packages/shared/src/features/scores/interfaces/api/v3/endpoints.tsindex 9ad89dd9eb..5ba703660f 100644--- a/packages/shared/src/features/scores/interfaces/api/v3/endpoints.ts+++ b/packages/shared/src/features/scores/interfaces/api/v3/endpoints.ts@@ -29,6 +29,8 @@ const csvStringParam = z).optional();+// Accepts case-insensitive input for uppercase enum allowedValues (e.g. "api"+// or "API" both parse to "API"). Downstream code only sees the canonical form.const csvEnumParam = <T extends readonly string[]>(allowedValues: T,label: string,@@ -39,7 +41,8 @@ const csvEnumParam = <T extends readonly string[]>(val.split(",").map((v) => v.trim())- .filter((v) => v.length > 0),+ .filter((v) => v.length > 0)+ .map((v) => v.toUpperCase()),).pipe(z.array(z.string()).superRefine((values, ctx) => {diff --git a/web/src/__tests__/server/unit/scores-api-v3.servertest.ts b/web/src/__tests__/server/unit/scores-api-v3.servertest.tsindex 77f113f2ef..c5655516e9 100644--- a/web/src/__tests__/server/unit/scores-api-v3.servertest.ts+++ b/web/src/__tests__/server/unit/scores-api-v3.servertest.ts@@ -1,4 +1,35 @@import { buildSelectColumns } from "@/src/features/public-api/server/scores-api-v3";+import { GetScoresQueryV3 } from "@langfuse/shared";++describe("GetScoresQueryV3 enum case-insensitivity", () => {+ it("accepts lowercase source values and normalizes to uppercase", () => {+ const parsed = GetScoresQueryV3.parse({ source: "api,annotation" });+ expect(parsed.source).toEqual(["API", "ANNOTATION"]);+ });++ it("accepts lowercase dataType values and normalizes to uppercase", () => {+ const parsed = GetScoresQueryV3.parse({ dataType: "numeric,boolean" });+ expect(parsed.dataType).toEqual(["NUMERIC", "BOOLEAN"]);+ });++ it("accepts mixed-case input", () => {+ const parsed = GetScoresQueryV3.parse({+ source: "Api,EVAL",+ dataType: "Numeric,categorical",+ });+ expect(parsed.source).toEqual(["API", "EVAL"]);+ expect(parsed.dataType).toEqual(["NUMERIC", "CATEGORICAL"]);+ });++ it("still rejects values that are not a valid enum after upper-casing", () => {+ expect(() => GetScoresQueryV3.parse({ source: "nope" })).toThrow(+ /Invalid source value/,+ );+ expect(() => GetScoresQueryV3.parse({ dataType: "string" })).toThrow(+ /Invalid dataType value/,+ );+ });+});describe("buildSelectColumns", () => {it("core always selects the polymorphic value columns", () => {