diff --git a/app/routes/api.chat.ts b/app/routes/api.chat.ts index a05d272c..aee5415e 100644 --- a/app/routes/api.chat.ts +++ b/app/routes/api.chat.ts @@ -196,10 +196,10 @@ export async function action({ ); } } - const message = - error instanceof Error ? error.message : "An error occurred."; - console.error(error); - return message; + // Log the full error server-side for debugging, but return a generic + // message to the client to avoid leaking stack traces or internal paths. + console.error("Chat stream error:", error); + return "An unexpected error occurred. Please try again later."; }, }); } diff --git a/src/api/test-setup.ts b/src/api/test-setup.ts index 928d7cd4..932eee02 100644 --- a/src/api/test-setup.ts +++ b/src/api/test-setup.ts @@ -56,15 +56,11 @@ export async function handleR2TestSetup( ); console.log(`Uploaded hardcoded content to ${file.bucketPath} in R2`); } catch (error) { - const errorMessage = - error instanceof Error ? error.message : String(error); console.error( `Error uploading hardcoded content to ${file.bucketPath} in R2:`, - errorMessage, - ); - results.push( - `Failed to upload hardcoded content to ${file.bucketPath}: ${errorMessage}`, + error, ); + results.push(`Failed to upload hardcoded content to ${file.bucketPath}`); errors++; } } diff --git a/src/api/tools/commonTools.ts b/src/api/tools/commonTools.ts index 090aeb97..0292f404 100644 --- a/src/api/tools/commonTools.ts +++ b/src/api/tools/commonTools.ts @@ -695,13 +695,13 @@ export async function searchRepositoryCode({ }, }; } catch (error) { - console.error(`Error in searchRepositoryCode: ${error}`); + console.error("Error in searchRepositoryCode:", error); return { searchQuery: query, content: [ { type: "text" as const, - text: `### Code Search Results for: "${query}"\n\nAn error occurred while searching code: ${error}`, + text: `### Code Search Results for: "${query}"\n\nAn error occurred while searching code. Please try again later.`, }, ], }; @@ -766,14 +766,14 @@ export async function fetchUrlContent({ url, env }: { url: string; env: Env }) { ], }; } catch (error) { - console.error(`Error fetching ${url}: ${error}`); + console.error(`Error fetching ${url}:`, error); return { url, status: "error", content: [ { type: "text" as const, - text: `Error fetching content from ${url}: ${error}`, + text: `Error fetching content from ${url}. Please try again later.`, }, ], };