Skip to content

Commit bfa41f9

Browse files
authored
fix: Sanitize error logs to prevent incorrect log level in Mezmo (#530)
1 parent 1f35b3d commit bfa41f9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/mcp/client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ export async function connectMCPClient(
4040
log.warning('Connection to MCP server using SSE transport timed out', { url, mcpSessionId });
4141
return null;
4242
}
43-
// External MCP server unavailability is operational, not a bug in our service
44-
log.softFail('Failed to connect to MCP server using SSE transport', {
43+
// External MCP server unavailability is operational, not a bug.
44+
// Mezmo (logDNA) promotes log entries to errors when the message contains "error"
45+
// Sanitize the error message to preserve the soft-fail log level.
46+
const errMessage = (error instanceof Error ? error.message : String(error)).replace(/ error:/gi, ' failure:');
47+
log.softFail('MCP server unreachable', {
4548
url,
4649
mcpSessionId,
4750
statusCode: getHttpStatusCode(error),
48-
errMessage: error instanceof Error ? error.message : String(error),
51+
errMessage,
4952
});
5053
return null;
5154
}

0 commit comments

Comments
 (0)