From 07e4ac6eae784bc8f9914ccf5706137490b93f53 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 08:16:33 +0000 Subject: [PATCH] fix(langfuse): use setTraceIO instead of updateTrace to match SDK API The LangfuseSpan type exposes setTraceIO(), not updateTrace(). The previous commit (6e1c978f) restored updateTrace which does not exist in the current SDK, causing TS2339 in both typecheck and Docker build. Co-Authored-By: Claude Opus 4.6 --- src/lib/langfuse/trace-proxy-request.ts | 2 +- tests/unit/langfuse/langfuse-trace.test.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/langfuse/trace-proxy-request.ts b/src/lib/langfuse/trace-proxy-request.ts index 2d4ec6bc3..09a23f7fd 100644 --- a/src/lib/langfuse/trace-proxy-request.ts +++ b/src/lib/langfuse/trace-proxy-request.ts @@ -408,7 +408,7 @@ export async function traceProxyRequest(ctx: TraceContext): Promise { ); // Explicitly set trace-level input/output (propagateAttributes does not support these) - rootSpan.updateTrace({ + rootSpan.setTraceIO({ input: actualRequestBody, output: actualResponseBody, }); diff --git a/tests/unit/langfuse/langfuse-trace.test.ts b/tests/unit/langfuse/langfuse-trace.test.ts index fb0871f62..3c3c105f8 100644 --- a/tests/unit/langfuse/langfuse-trace.test.ts +++ b/tests/unit/langfuse/langfuse-trace.test.ts @@ -25,11 +25,11 @@ const mockEventObs: any = { end: mockEventEnd, }; -const mockUpdateTrace = vi.fn(); +const mockSetTraceIO = vi.fn(); const mockRootSpan = { startObservation: vi.fn(), - updateTrace: mockUpdateTrace, + setTraceIO: mockSetTraceIO, end: mockSpanEnd, }; @@ -537,7 +537,7 @@ describe("traceProxyRequest", () => { (c: unknown[]) => c[0] === "llm-call" ); expect(llmCall[1].output).toEqual(expectedOutput); - expect(mockRootSpan.updateTrace).toHaveBeenCalledWith( + expect(mockRootSpan.setTraceIO).toHaveBeenCalledWith( expect.objectContaining({ output: expectedOutput, }) @@ -575,7 +575,7 @@ describe("traceProxyRequest", () => { (c: unknown[]) => c[0] === "llm-call" ); expect(llmCall[1].output).toEqual(expectedOutput); - expect(mockRootSpan.updateTrace).toHaveBeenCalledWith( + expect(mockRootSpan.setTraceIO).toHaveBeenCalledWith( expect.objectContaining({ output: expectedOutput, }) @@ -602,7 +602,7 @@ describe("traceProxyRequest", () => { ); }); - test("should set trace-level input/output via updateTrace with actual bodies", async () => { + test("should set trace-level input/output via setTraceIO with actual bodies", async () => { const { traceProxyRequest } = await import("@/lib/langfuse/trace-proxy-request"); const responseBody = { result: "ok" }; @@ -616,7 +616,7 @@ describe("traceProxyRequest", () => { costUsd: "0.05", }); - expect(mockUpdateTrace).toHaveBeenCalledWith({ + expect(mockSetTraceIO).toHaveBeenCalledWith({ input: expect.objectContaining({ model: "claude-sonnet-4-20250514", messages: expect.any(Array), @@ -882,8 +882,8 @@ describe("traceProxyRequest", () => { const rootCall = mockStartObservation.mock.calls[0]; expect(rootCall[1].input).toEqual(JSON.parse(forwardedBody)); - // updateTrace should also use forwarded body - expect(mockUpdateTrace).toHaveBeenCalledWith({ + // setTraceIO should also use forwarded body + expect(mockSetTraceIO).toHaveBeenCalledWith({ input: JSON.parse(forwardedBody), output: { ok: true }, });