Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: render non-Zod and array-path detail entries readably in the route-error log
[._.]/ Adam Eivyb6e62a429ebd
diff --git a/server/lib/errorHandler.js b/server/lib/errorHandler.jsindex cd44287136..58f24be52b 100644--- a/server/lib/errorHandler.js+++ b/server/lib/errorHandler.js@@ -127,11 +127,19 @@ const clampLogText = (value) => {return flat.length > LOG_DETAIL_MAX_CHARS ? `${flat.slice(0, LOG_DETAIL_MAX_CHARS)}…` : flat;};+const describeObjectEntries = (obj) => Object.entries(obj).map(([k, v]) => `${k}=${v}`).join('; ');+const describeDetailEntry = (entry) => {if (!entry || typeof entry !== 'object') return String(entry);- const { path, message } = entry;- if (path && message) return `${path}: ${message}`;- return String(message || path || '?');+ // `validate`/`validateRequest` pre-join the Zod path, but a caller passing raw+ // issues through would leave an array — render it as dot notation, not CSV.+ const path = Array.isArray(entry.path) ? entry.path.join('.') : entry.path;+ const { message } = entry;+ // Nullish, not truthy: a `message` of `0`/`false` is still a message.+ if (path != null && message != null) return `${path}: ${message}`;+ if (path != null || message != null) return String(message ?? path);+ // Not a Zod-shaped issue — name its own fields rather than logging a bare '?'.+ return describeObjectEntries(entry) || '?';};/**@@ -154,9 +162,7 @@ const summarizeDetails = (details) => {const elided = details.length - LOG_DETAIL_MAX_ENTRIES;return elided > 0 ? `${shown} (+${elided} more)` : shown;}- if (details && typeof details === 'object') {- return clampLogText(Object.entries(details).map(([k, v]) => `${k}=${v}`).join('; '));- }+ if (details && typeof details === 'object') return clampLogText(describeObjectEntries(details));return clampLogText(details);};@@ -186,8 +192,10 @@ export function asyncHandler(fn) {} else if (error.status >= 500) {console.error(logMsg, error.stack ? error.stack : '');} else {- const details = error.context?.details;- console.error(details ? `${logMsg}: ${summarizeDetails(details)}` : logMsg);+ // An empty `[]`/`{}` is truthy but summarizes to nothing — gate on the+ // summary so the line can't end in a dangling colon.+ const summary = error.context?.details ? summarizeDetails(error.context.details) : '';+ console.error(summary ? `${logMsg}: ${summary}` : logMsg);}return sendErrorResponse(res, error, { io });diff --git a/server/lib/errorHandler.test.js b/server/lib/errorHandler.test.jsindex 2974592e21..47d5e4f42d 100644--- a/server/lib/errorHandler.test.js+++ b/server/lib/errorHandler.test.js@@ -522,6 +522,18 @@ describe('errorHandler.js', () => {expect(line.endsWith('…')).toBe(true);});+ // `[]` and `{}` are truthy but summarize to nothing.+ it('omits the details segment entirely when it summarizes to nothing', async () => {+ const { req, res } = makeReqRes(null);++ await asyncHandler(async () => {+ throw new ServerError('Validation failed', { status: 400, context: { details: [] } });+ })(req, res, vi.fn());+ await flushMicrotasks();++ expect(errorSpy.mock.calls[0][0]).toBe('❌ Route error [GET /api/thing]: Validation failed');+ });+// The 500 branch logs the stack, not `details` — it must stay untouched.it('leaves the 500 stack branch alone', async () => {const { req, res } = makeReqRes(null);