{"record":{"id":"a787831735594ad8","repo":"modelcontextprotocol/servers","slug":"error-processing-file-datauri-error-instance","errorCode":null,"errorMessage":"Error processing file ${dataUri}: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Error processing file (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/everything/tools/gzip-file-as-resource.ts","lineNumber":161,"sourceCode":"    ) {\n      throw new Error(\n        `Unsupported URL protocol for ${dataUri}. Only http, https, and data URLs are supported.`\n      );\n    }\n    if (\n      GZIP_ALLOWED_DOMAINS.length > 0 &&\n      (url.protocol === \"http:\" || url.protocol === \"https:\")\n    ) {\n      const domain = url.hostname;\n      const domainAllowed = GZIP_ALLOWED_DOMAINS.some((allowedDomain) => {\n        return domain === allowedDomain || domain.endsWith(`.${allowedDomain}`);\n      });\n      if (!domainAllowed) {\n        throw new Error(`Domain ${domain} is not in the allowed domains list.`);\n      }\n    }\n  } catch (error) {\n    throw new Error(\n      `Error processing file ${dataUri}: ${\n        error instanceof Error ? error.message : String(error)\n      }`\n    );\n  }\n  return url;\n}\n\n/**\n * Fetches data safely from a given URL while ensuring constraints on maximum byte size and timeout duration.\n *\n * @param {URL} url The URL to fetch data from.\n * @param {Object} options An object containing options for the fetch operation.\n * @param {number} options.maxBytes The maximum allowed size (in bytes) of the response. If the response exceeds this size, the operation will be aborted.\n * @param {number} options.timeoutMillis The timeout duration (in milliseconds) for the fetch operation. If the fetch takes longer, it will be aborted.\n * @return {Promise<ArrayBuffer>} A promise that resolves with the response as an ArrayBuffer if successful.\n * @throws {Error} Throws an error if the response size exceeds the defined limit, the fetch times out, or the response is otherwise invalid.\n */","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/everything/tools/gzip-file-as-resource.ts#L143-L179","documentation":"A wrapper error thrown by the `catch` block of `validateDataURI`. Any inner error (unsupported protocol, disallowed domain, or a URL-parse failure inside the try) is re-thrown with this prefixed message that includes the original `dataUri` and the inner error's message. It exists to give a single, consistent error shape for all data-URI validation failures.","triggerScenarios":"Any failure inside `validateDataURI`'s try block: unsupported protocol (error 7), disallowed domain (error 8), or a thrown `TypeError` from `new URL()` — although note `new URL()` runs before the try, so the most common inner causes are the protocol and domain throws.","commonSituations":"Operators see this wrapper instead of the specific cause when reading logs; the inner message is preserved in the text. Common when chaining multiple validation rules and the first to fail is wrapped generically.","solutions":["Read the inner message embedded in the wrapper text — it identifies the actual cause (protocol or domain).","Fix the underlying issue per errors 7 or 8 (use a supported protocol; allowlist the domain).","If your URL is malformed, ensure it parses with `new URL()` under a supported scheme before calling the tool."],"exampleFix":"// the wrapper surfaces the real cause; fix the root issue\n// before: data uses 'file://'  -> wrapper: \"Error processing file file:///x: Unsupported URL protocol...\"\n// after:  data uses 'https://' -> no error","handlingStrategy":"try-catch","validationCode":"function validateDataUriClient(s: string): URL | Error {\n  try {\n    const u = new URL(s);\n    if (!['http:','https:','data:'].includes(u.protocol)) return new Error('protocol');\n    // domain check mirroring server rules omitted for brevity\n    return u;\n  } catch (e) { return e as Error; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await callGzipTool({ data: url });\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg.startsWith('Error processing file')) {\n    // inner cause is embedded in the message text\n    const cause = msg.split(':').slice(2).join(':').trim();\n    // branch on cause: protocol vs domain vs parse\n  }\n}","preventionTips":["Parse the inner cause from the wrapper message to identify the real failure.","Pre-validate the URL scheme and domain client-side (see errors 7 and 8).","Treat this wrapper as a catch-all; fix the specific inner issue."],"tags":["mcp","typescript","everything-server","error-wrapping","network","validation"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}