From aa25bcc053806968bfc425a405fcff81c7c12b62 Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 10 Jun 2026 17:02:13 -0700 Subject: [PATCH] fix: always expose DC-prefixed errors to users in safeErrorMessage --- dashcaddy-api/src/utils/logging.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dashcaddy-api/src/utils/logging.js b/dashcaddy-api/src/utils/logging.js index 089e671..887444c 100644 --- a/dashcaddy-api/src/utils/logging.js +++ b/dashcaddy-api/src/utils/logging.js @@ -97,6 +97,9 @@ function safeErrorMessage(error) { if (!error) return 'An internal error occurred'; const msg = error.message || String(error); + // Always expose DC-prefixed user-facing errors + if (/\[DC-\d+\]/.test(msg)) return msg; + // Detect port conflict errors const portMatch = msg.match(/exposing port TCP [^:]*:(\d+)/); if (portMatch || msg.includes('port is already allocated') || msg.includes('ports are not available')) { @@ -104,7 +107,7 @@ function safeErrorMessage(error) { return `[DC-200] Port ${port} is already in use. Try a different port or stop the service using that port first.`; } - // Only expose short, user-facing messages + // Only expose short, user-facing messages (no paths, stack traces, or internal details) if (msg.length < 200 && !msg.includes('/') && !msg.includes('\\') && !msg.includes(' at ')) { return msg; }