Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(observations-v2): retire parseIoAsJson option, return 400 when set to true (#11990)

Valery Meleshkin8c1e50adcf28
diff --git a/fern/apis/server/definition/observations-v2.yml b/fern/apis/server/definition/observations-v2.yml
index 6d5638ca49..93dcb5bc8d 100644
--- a/fern/apis/server/definition/observations-v2.yml
+++ b/fern/apis/server/definition/observations-v2.yml
@@ -59,8 +59,9 @@ service:
parseIoAsJson:
type: optional<boolean>
docs: |
- Set to `true` to parse input/output fields as JSON, or `false` to return raw strings.
- Defaults to `false` if not provided.
+ **Deprecated.** Setting this to `true` will return a 400 error.
+ Input/output fields are always returned as raw strings.
+ Remove this parameter or set it to `false`.
name: optional<string>
userId: optional<string>
type:
diff --git a/packages/shared/src/server/repositories/events.ts b/packages/shared/src/server/repositories/events.ts
index b5128280ef..61e60b1c68 100644
--- a/packages/shared/src/server/repositories/events.ts
+++ b/packages/shared/src/server/repositories/events.ts
@@ -1104,8 +1104,8 @@ export const getObservationsV2FromEventsTableForPublicApi = async (
return await enrichObservationsWithModelData(
records,
projectId,
- Boolean(opts.parseIoAsJson),
- opts.fields,
+ false, // V2 API: IO fields are always returned as raw strings
+ opts.fields, // V2 API: field groups specified, return partial observations
);
};
diff --git a/web/src/__tests__/async/observations-api-v2.servertest.ts b/web/src/__tests__/async/observations-api-v2.servertest.ts
index ffb71ff005..6a04620b95 100644
--- a/web/src/__tests__/async/observations-api-v2.servertest.ts
+++ b/web/src/__tests__/async/observations-api-v2.servertest.ts
@@ -131,48 +131,16 @@ describe("/api/public/v2/observations API Endpoint", () => {
expect(obs?.output).toBe(jsonOutput);
});
- it("should parse input/output as JSON when parseIoAsJson=true", async () => {
- const traceId = randomUUID();
- const observationId = randomUUID();
- const timestamp = new Date();
- const timeValue = timestamp.getTime() * 1000;
-
- // Create observation with JSON input/output
- const inputData = { question: "What is 2+2?" };
- const outputData = { answer: 4 };
-
- const observation = createEvent({
- id: observationId,
- span_id: observationId,
- trace_id: traceId,
- project_id: projectId,
- name: "test-observation",
- type: "GENERATION",
- level: "DEFAULT",
- start_time: timeValue,
- end_time: timeValue + 1000 * 1000,
- input: JSON.stringify(inputData),
- output: JSON.stringify(outputData),
- });
-
- await createEventsCh([observation]);
-
- // Request with parseIoAsJson=true
- const response = await makeZodVerifiedAPICall(
- GetObservationsV2Response,
+ it("should return 400 when parseIoAsJson=true", async () => {
+ const { makeAPICall } = await import("@/src/__tests__/test-utils");
+ const response = await makeAPICall(
"GET",
- `/api/public/v2/observations?fields=io&traceId=${traceId}&parseIoAsJson=true`,
+ `/api/public/v2/observations?fields=io&parseIoAsJson=true`,
);
- expect(response.status).toBe(200);
- const obs = response.body.data.find((o: any) => o.id === observationId);
- expect(obs).toBeDefined();
-
- // Input and output should be parsed as objects
- expect(typeof obs?.input).toBe("object");
- expect(typeof obs?.output).toBe("object");
- expect(obs?.input).toEqual(inputData);
- expect(obs?.output).toEqual(outputData);
+ expect(response.status).toBe(400);
+ expect(response.body).toHaveProperty("error");
+ expect(JSON.stringify(response.body)).toContain("parseIoAsJson");
});
it("should respect limit parameter with default of 50", async () => {
diff --git a/web/src/features/public-api/types/observations.ts b/web/src/features/public-api/types/observations.ts
index adc0b405e8..5ed2c8af35 100644
--- a/web/src/features/public-api/types/observations.ts
+++ b/web/src/features/public-api/types/observations.ts
@@ -318,11 +318,14 @@ export const GetObservationsV2Query = z.object({
// Pagination
limit: z.coerce.number().nonnegative().lte(1000).default(50),
cursor: EncodedObservationsCursorV2.optional(),
- // Parsing behavior
+ // Parsing behavior - parseIoAsJson=true is retired, IO is always returned as raw strings
parseIoAsJson: z
.union([z.literal("true"), z.literal("false")])
- .transform((val) => val === "true")
- .default(false),
+ .refine((val) => val !== "true", {
+ message:
+ "parseIoAsJson=true is no longer supported on the v2 observations endpoint. Input/output fields are always returned as raw strings. Remove the parseIoAsJson parameter or set it to false.",
+ })
+ .optional(),
// Filters
type: ObservationType.nullish(),
name: z.string().nullish(),
diff --git a/web/src/pages/api/public/v2/observations/index.ts b/web/src/pages/api/public/v2/observations/index.ts
index a7282af21b..a35fa7aed9 100644
--- a/web/src/pages/api/public/v2/observations/index.ts
+++ b/web/src/pages/api/public/v2/observations/index.ts
@@ -42,7 +42,6 @@ export default withMiddlewares({
toStartTime: query.toStartTime ?? undefined,
version: query.version ?? undefined,
advancedFilters: query.filter,
- parseIoAsJson: query.parseIoAsJson ?? false,
cursor: query.cursor ?? undefined,
fields: fieldGroups,
expandMetadataKeys,