Skip to main content
Glama
error-sanitization-utils.js1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizeErrorMessageCore = sanitizeErrorMessageCore; const logger_1 = require("../utils/logger"); function sanitizeErrorMessageCore(errorMessage) { try { const maxLength = 1500; const trimmed = errorMessage.length > maxLength ? errorMessage.substring(0, maxLength) : errorMessage; const lines = trimmed.split('\n'); let sanitized = lines.slice(0, 3).join('\n'); sanitized = sanitized.replace(/https?:\/\/\S+/gi, '[URL]'); sanitized = sanitized .replace(/AKIA[A-Z0-9]{16}/g, '[AWS_KEY]') .replace(/ghp_[a-zA-Z0-9]{36,}/g, '[GITHUB_TOKEN]') .replace(/eyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+/g, '[JWT]') .replace(/Bearer\s+[^\s]+/gi, 'Bearer [TOKEN]'); sanitized = sanitized.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, '[EMAIL]'); sanitized = sanitized .replace(/\b[a-zA-Z0-9_-]{32,}\b/g, '[KEY]') .replace(/(['"])[a-zA-Z0-9_-]{16,}\1/g, '$1[TOKEN]$1'); sanitized = sanitized .replace(/password\s*[=:]\s*\S+/gi, 'password=[REDACTED]') .replace(/api[_-]?key\s*[=:]\s*\S+/gi, 'api_key=[REDACTED]') .replace(/\btoken\s*[=:]\s*[^\s;,)]+/gi, 'token=[REDACTED]'); if (sanitized.length > 500) { sanitized = sanitized.substring(0, 500) + '...'; } return sanitized; } catch (error) { logger_1.logger.debug('Error message sanitization failed:', error); return '[SANITIZATION_FAILED]'; } } //# sourceMappingURL=error-sanitization-utils.js.map

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/czlonkowski/n8n-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server