From 09ae5309d42c1101f57c4100e8c0acb45fe38490 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 11:23:06 +0000 Subject: [PATCH] Clamp and validate DB_CONNECT_RETRIES and DB_CONNECT_RETRY_DELAY_MS env vars Agent-Logs-Url: https://github.com/gabriel20xx/CollabTable/sessions/3d38d5f2-ce12-45a3-bcfe-9fb96f3581ce Co-authored-by: gabriel20xx <21219769+gabriel20xx@users.noreply.github.com> --- CollabTableServer/src/db.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CollabTableServer/src/db.ts b/CollabTableServer/src/db.ts index c891139..d177ef4 100644 --- a/CollabTableServer/src/db.ts +++ b/CollabTableServer/src/db.ts @@ -296,8 +296,11 @@ export const dbAdapter: DBAdapter = clientType === 'postgres' || clientType === : new SqliteAdapter(); export async function initializeDatabase() { - const maxRetries = parseInt(process.env.DB_CONNECT_RETRIES || '10', 10); - const retryDelayMs = parseInt(process.env.DB_CONNECT_RETRY_DELAY_MS || '3000', 10); + const parsedRetries = parseInt(process.env.DB_CONNECT_RETRIES || '10', 10); + const maxRetries = Number.isNaN(parsedRetries) || parsedRetries < 1 ? 10 : parsedRetries; + + const parsedDelay = parseInt(process.env.DB_CONNECT_RETRY_DELAY_MS || '3000', 10); + const retryDelayMs = Number.isNaN(parsedDelay) || parsedDelay < 0 ? 3000 : parsedDelay; for (let attempt = 1; attempt <= maxRetries; attempt++) { try {