🪢 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): reject unknown query params on v3 list endpoint (#14093)
Niklas Semmler0721ac483c65
diff --git a/fern/apis/server/_drafts/scores-v3.yml b/fern/apis/server/_drafts/scores-v3.ymlindex 282db893db..2c648556f3 100644--- a/fern/apis/server/_drafts/scores-v3.yml+++ b/fern/apis/server/_drafts/scores-v3.yml@@ -18,6 +18,9 @@ service:Use the `fields` parameter to include optional field groups beyond thedefault `core`. Unknown group names return HTTP 400.+ Unknown query parameters (e.g. `field` instead of `fields`) return HTTP+ 400 rather than being silently ignored.+Currently in preview for Langfuse Cloud v4 users; not yet available onself-hosted Langfuse.method: GETdiff --git a/packages/shared/src/features/scores/interfaces/api/v3/endpoints.ts b/packages/shared/src/features/scores/interfaces/api/v3/endpoints.tsindex 5ba703660f..68e95ebe7d 100644--- a/packages/shared/src/features/scores/interfaces/api/v3/endpoints.ts+++ b/packages/shared/src/features/scores/interfaces/api/v3/endpoints.ts@@ -58,59 +58,62 @@ const csvEnumParam = <T extends readonly string[]>().optional();-// GET /v3/scores — all filter params optional; superRefine validation lives in the handler.-export const GetScoresQueryV3 = z.object({- limit: z.coerce.number().int().positive().max(100).default(50),- fields: fieldsParam,- // Identifier filters (multi-value, comma-separated)- id: csvStringParam,- name: csvStringParam,- source: csvEnumParam(ScoreSourceArray, "source"),- dataType: csvEnumParam(ScoreDataTypeArray, "dataType"),- environment: csvStringParam,- configId: csvStringParam,- queueId: csvStringParam,- authorUserId: csvStringParam,- // Value filters- value: csvStringParam,- // Treat empty string as absent so `?valueMin=` doesn't silently coerce to 0- // and narrow results to `value >= 0`. Zod 4 rejects ±Infinity / NaN out of- // the box, so `.finite()` is not needed.- valueMin: z.preprocess(- (v) => (v === "" ? undefined : v),- z.coerce.number().optional(),- ),- valueMax: z.preprocess(- (v) => (v === "" ? undefined : v),- z.coerce.number().optional(),- ),- // Entity-bounded filters- traceId: csvStringParam,- sessionId: csvStringParam,- observationId: csvStringParam,- experimentId: csvStringParam,- // Timestamp filters — preprocess empty string to undefined so ?fromTimestamp=- // from a templating system is treated as absent, consistent with valueMin/valueMax.- fromTimestamp: z.preprocess(- (v) => (v === "" ? undefined : v),- z.coerce.date().optional(),- ),- toTimestamp: z.preprocess(- (v) => (v === "" ? undefined : v),- z.coerce.date().optional(),- ),- // Deferred params (always → 400 — require trace JOIN not present in v3).- // Treat the empty string as absent so a stray `?userId=` from a templating- // system doesn't trigger the "use v2" 400 spuriously.- userId: z- .string()- .optional()- .transform((v) => (v === "" ? undefined : v)),- traceTags: z- .string()- .optional()- .transform((v) => (v === "" ? undefined : v)),-});+// GET /v3/scores — all filter params optional; unknown query params return 400 via .strict();+// cross-field superRefine validation lives in the handler.+export const GetScoresQueryV3 = z+ .object({+ limit: z.coerce.number().int().positive().max(100).default(50),+ fields: fieldsParam,+ // Identifier filters (multi-value, comma-separated)+ id: csvStringParam,+ name: csvStringParam,+ source: csvEnumParam(ScoreSourceArray, "source"),+ dataType: csvEnumParam(ScoreDataTypeArray, "dataType"),+ environment: csvStringParam,+ configId: csvStringParam,+ queueId: csvStringParam,+ authorUserId: csvStringParam,+ // Value filters+ value: csvStringParam,+ // Treat empty string as absent so `?valueMin=` doesn't silently coerce to 0+ // and narrow results to `value >= 0`. Zod 4 rejects ±Infinity / NaN out of+ // the box, so `.finite()` is not needed.+ valueMin: z.preprocess(+ (v) => (v === "" ? undefined : v),+ z.coerce.number().optional(),+ ),+ valueMax: z.preprocess(+ (v) => (v === "" ? undefined : v),+ z.coerce.number().optional(),+ ),+ // Entity-bounded filters+ traceId: csvStringParam,+ sessionId: csvStringParam,+ observationId: csvStringParam,+ experimentId: csvStringParam,+ // Timestamp filters — preprocess empty string to undefined so ?fromTimestamp=+ // from a templating system is treated as absent, consistent with valueMin/valueMax.+ fromTimestamp: z.preprocess(+ (v) => (v === "" ? undefined : v),+ z.coerce.date().optional(),+ ),+ toTimestamp: z.preprocess(+ (v) => (v === "" ? undefined : v),+ z.coerce.date().optional(),+ ),+ // Deferred params (always → 400 — require trace JOIN not present in v3).+ // Treat the empty string as absent so a stray `?userId=` from a templating+ // system doesn't trigger the "use v2" 400 spuriously.+ userId: z+ .string()+ .optional()+ .transform((v) => (v === "" ? undefined : v)),+ traceTags: z+ .string()+ .optional()+ .transform((v) => (v === "" ? undefined : v)),+ })+ .strict();export const GetScoresResponseV3 = z.object({data: z.array(APIScoreSchemaV3),