Skip to content

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

chore: restrict trace.name length to 1000 characters (#4441)

Steffen Schmitz44ba6eaddfa6
diff --git a/packages/shared/src/server/ingestion/types.ts b/packages/shared/src/server/ingestion/types.ts
index bb61bbb03b..689ca9f458 100644
--- a/packages/shared/src/server/ingestion/types.ts
+++ b/packages/shared/src/server/ingestion/types.ts
@@ -59,7 +59,7 @@ export const usage = MixedUsage.nullish()
export const TraceBody = z.object({
id: z.string().nullish(),
timestamp: stringDateTime,
- name: z.string().nullish(),
+ name: z.string().max(1000).nullish(),
externalId: z.string().nullish(),
input: jsonSchema.nullish(),
output: jsonSchema.nullish(),
diff --git a/web/src/__tests__/ingestion.servertest.ts b/web/src/__tests__/ingestion.servertest.ts
index 9ed990fde5..e199559938 100644
--- a/web/src/__tests__/ingestion.servertest.ts
+++ b/web/src/__tests__/ingestion.servertest.ts
@@ -978,6 +978,39 @@ describe("/api/public/ingestion API Endpoint", () => {
expect(dbTrace.length).toBe(1);
});
+ it("should fail for long trace name", async () => {
+ const traceId = v4();
+
+ const baseString =
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ";
+ const repeatCount = Math.ceil(1500 / baseString.length);
+ const name = baseString.repeat(repeatCount);
+
+ const response = await makeAPICall("POST", "/api/public/ingestion", {
+ batch: [
+ {
+ id: v4(),
+ type: "trace-create",
+ timestamp: new Date().toISOString(),
+ body: {
+ id: traceId,
+ name,
+ userId: "user-1",
+ metadata: { key: "value" },
+ release: "1.0.0",
+ version: "2.0.0",
+ },
+ },
+ ],
+ });
+
+ expect(response.status).toBe(207);
+ expect("errors" in response.body).toBe(true);
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
+ expect(response.body.errors.length).toBe(1);
+ expect(response.body.errors[0].message).toBe("Invalid request data");
+ });
+
it("should update all token counts if update does not contain model name", async () => {
const traceId = v4();
const generationId = v4();