From 173cdcf04b6e8f0e213115f237f7f0530ab4858e Mon Sep 17 00:00:00 2001 From: Kashish Hora Date: Mon, 24 Nov 2025 22:09:31 +0100 Subject: [PATCH] hotfix to return undefined error type in missed places --- src/modules/exceptions.ts | 4 ++-- src/tests/error-capture.test.ts | 12 +++++++----- src/tests/exceptions.test.ts | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/modules/exceptions.ts b/src/modules/exceptions.ts index 12845ce..8b140d3 100644 --- a/src/modules/exceptions.ts +++ b/src/modules/exceptions.ts @@ -686,7 +686,7 @@ function unwrapErrorCauses(error: Error): ChainedErrorData[] { if (!(currentError instanceof Error)) { chainedErrors.push({ message: stringifyNonError(currentError), - type: "UnknownErrorType", + type: undefined, }); break; } @@ -760,7 +760,7 @@ function captureCallToolResultError( const errorData: ErrorData = { message, - type: "UnknownErrorType", // Can't determine actual type from CallToolResult + type: undefined, // Can't determine actual type from CallToolResult platform: "javascript", // No stack or frames - SDK stripped the original error information }; diff --git a/src/tests/error-capture.test.ts b/src/tests/error-capture.test.ts index 2f5ee85..079dc26 100644 --- a/src/tests/error-capture.test.ts +++ b/src/tests/error-capture.test.ts @@ -237,7 +237,7 @@ describe("Error Capture Integration Tests", () => { const errorEvent = events.find((e) => e.isError); expect(errorEvent).toBeDefined(); - expect(errorEvent!.error!.type).toBe("UnknownErrorType"); + expect(errorEvent!.error!.type).toBeUndefined(); expect(errorEvent!.error!.message).toContain("This is a string error"); // Non-Error throws don't have stack traces // (SDK converts them, we can't capture at callback level) @@ -486,8 +486,8 @@ describe("Error Capture Integration Tests", () => { expect(errorEvent!.error!.message).toContain("Invalid"); // Type can vary by SDK version - // SDK 1.11.5: "McpError", SDK 1.21.0+: "UnknownErrorType" - expect(["McpError", "UnknownErrorType", "Error"]).toContain( + // SDK 1.11.5: "McpError" (actual Error), SDK 1.21.0+: undefined (CallToolResult) + expect(["McpError", "Error", undefined]).toContain( errorEvent!.error!.type, ); @@ -550,7 +550,8 @@ describe("Error Capture Integration Tests", () => { expect(errorEvent!.error!.message).toContain("not found"); // Type can vary by SDK version - expect(["McpError", "UnknownErrorType", "Error"]).toContain( + // SDK 1.11.5: "McpError" (actual Error), SDK 1.21.0+: undefined (CallToolResult) + expect(["McpError", "Error", undefined]).toContain( errorEvent!.error!.type, ); @@ -606,7 +607,8 @@ describe("Error Capture Integration Tests", () => { expect(errorEvent!.error!.message).toContain("Invalid"); // Type can vary by SDK version - expect(["McpError", "UnknownErrorType", "Error"]).toContain( + // SDK 1.11.5: "McpError" (actual Error), SDK 1.21.0+: undefined (CallToolResult) + expect(["McpError", "Error", undefined]).toContain( errorEvent!.error!.type, ); diff --git a/src/tests/exceptions.test.ts b/src/tests/exceptions.test.ts index 54c2637..35c05a7 100644 --- a/src/tests/exceptions.test.ts +++ b/src/tests/exceptions.test.ts @@ -272,7 +272,7 @@ describe("captureException", () => { expect(result.chained_errors).toBeDefined(); expect(result.chained_errors!.length).toBe(1); expect(result.chained_errors![0].message).toBe("string cause"); - expect(result.chained_errors![0].type).toBe("UnknownErrorType"); + expect(result.chained_errors![0].type).toBeUndefined(); }); it("should detect circular cause references", () => {