Skip to content

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

chore: reproduce clickhouse missing surrogate key error (#5980)

Steffen Schmitzbb1dbdf82486
diff --git a/packages/shared/src/server/clickhouse/client.ts b/packages/shared/src/server/clickhouse/client.ts
index 9377dc5dd2..bd7c452448 100644
--- a/packages/shared/src/server/clickhouse/client.ts
+++ b/packages/shared/src/server/clickhouse/client.ts
@@ -29,6 +29,7 @@ export const clickhouseClient = (
log_comment: JSON.stringify(params.tags ?? {}),
async_insert: 1,
wait_for_async_insert: 1, // if disabled, we won't get errors from clickhouse
+ input_format_json_throw_on_bad_escape_sequence: 0,
},
});
};
diff --git a/web/src/__tests__/async/ingestion-api.servertest.ts b/web/src/__tests__/async/ingestion-api.servertest.ts
index a87d91da21..d95c12919f 100644
--- a/web/src/__tests__/async/ingestion-api.servertest.ts
+++ b/web/src/__tests__/async/ingestion-api.servertest.ts
@@ -69,6 +69,21 @@ describe("/api/public/ingestion API Endpoint", () => {
},
},
],
+ [
+ "emojis in i/o",
+ {
+ id: randomUUID(),
+ type: "trace-create",
+ timestamp: new Date().toISOString(),
+ body: {
+ id: randomUUID(),
+ timestamp: new Date().toISOString(),
+ metadata: { hello: "world" },
+ input: "🪢🚀🌖",
+ output: "👋🌍",
+ },
+ },
+ ],
])(
"should create traces via the ingestion API (%s)",
async (_name: string, entity: any) => {
@@ -93,6 +108,33 @@ describe("/api/public/ingestion API Endpoint", () => {
},
);
+ it("should replace bad escape sequences on clickhouse", async () => {
+ const entity = {
+ id: randomUUID(),
+ type: "trace-create",
+ timestamp: new Date().toISOString(),
+ body: {
+ id: randomUUID(),
+ timestamp: new Date().toISOString(),
+ metadata: { hello: "world" },
+ input: "test\\ud8000test",
+ environment: "production",
+ },
+ };
+ const response = await makeAPICall("POST", "/api/public/ingestion", {
+ batch: [entity],
+ });
+
+ expect(response.status).toBe(207);
+ await waitForExpect(async () => {
+ const trace = await getTraceById(entity.body.id, projectId);
+ expect(trace).toBeDefined();
+ expect(trace!.id).toBe(entity.body.id);
+ expect(trace!.projectId).toBe(projectId);
+ expect(trace!.input).toContain("test");
+ });
+ });
+
it.each([
[
"generation",