From a8a5d1ab934a17625e2be0547b391c399075a844 Mon Sep 17 00:00:00 2001 From: openhands Date: Fri, 6 Mar 2026 05:02:10 +0000 Subject: [PATCH 1/2] fix: getErrorMessage silently ignores viem's shortMessage (#430) viem's BaseError extends Error, so the instanceof Error branch was firing and returning error.message before the isRecord branch could check shortMessage. Check shortMessage first inside instanceof Error so terse viem messages are shown to users instead of verbose full ones. Co-Authored-By: Claude Sonnet 4.6 --- packages/utils/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index aebb78d..fe49542 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -14,6 +14,9 @@ export function coerceString(value: unknown): string | null { export function getErrorMessage(error: unknown, fallback: string): string { if (error instanceof Error) { + // viem's BaseError extends Error and exposes a terse shortMessage; prefer it. + const short = coerceString((error as Record).shortMessage); + if (short) return short; const msg = coerceString(error.message); if (msg) return msg; } From fc008fb9c1794268695c1445e95c915373366480 Mon Sep 17 00:00:00 2001 From: openhands Date: Fri, 6 Mar 2026 05:13:27 +0000 Subject: [PATCH 2/2] fix: correct TypeScript cast for shortMessage in getErrorMessage (#430) The direct cast of Error to Record is rejected by TypeScript because the types don't sufficiently overlap. Cast via unknown first to satisfy the compiler. Co-Authored-By: Claude Sonnet 4.6 --- packages/utils/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index fe49542..0441153 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -15,7 +15,7 @@ export function coerceString(value: unknown): string | null { export function getErrorMessage(error: unknown, fallback: string): string { if (error instanceof Error) { // viem's BaseError extends Error and exposes a terse shortMessage; prefer it. - const short = coerceString((error as Record).shortMessage); + const short = coerceString((error as unknown as Record).shortMessage); if (short) return short; const msg = coerceString(error.message); if (msg) return msg;