{"record":{"id":"f4b5b94cbf5e74eb","repo":"modelcontextprotocol/servers","slug":"no-response-body","errorCode":null,"errorMessage":"No response body","messagePattern":"No response body","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/everything/tools/gzip-file-as-resource.ts","lineNumber":197,"sourceCode":" */\nasync function fetchSafely(\n  url: URL,\n  { maxBytes, timeoutMillis }: { maxBytes: number; timeoutMillis: number }\n): Promise<ArrayBuffer> {\n  const controller = new AbortController();\n  const timeout = setTimeout(\n    () =>\n      controller.abort(\n        `Fetching ${url} took more than ${timeoutMillis} ms and was aborted.`\n      ),\n    timeoutMillis\n  );\n\n  try {\n    // Fetch the data\n    const response = await fetch(url, { signal: controller.signal });\n    if (!response.body) {\n      throw new Error(\"No response body\");\n    }\n\n    // Note: we can't trust the Content-Length header: a malicious or clumsy server could return much more data than advertised.\n    // We check it here for early bail-out, but we still need to monitor actual bytes read below.\n    const contentLengthHeader = response.headers.get(\"content-length\");\n    if (contentLengthHeader != null) {\n      const contentLength = parseInt(contentLengthHeader, 10);\n      if (contentLength > maxBytes) {\n        throw new Error(\n          `Content-Length for ${url} exceeds max of ${maxBytes}: ${contentLength}`\n        );\n      }\n    }\n\n    // Read the fetched data from the response body\n    const reader = response.body.getReader();\n    const chunks = [];\n    let totalSize = 0;","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/everything/tools/gzip-file-as-resource.ts#L179-L215","documentation":"Thrown by `fetchSafely` when the fetch response has a null/absent body (`response.body` is falsy). This guards the streaming reader logic, which assumes a readable body exists. Common for responses that carry all data in headers or for certain error responses.","triggerScenarios":"The remote server returns a response with no body (e.g. a 204 No Content, a HEAD-style response, or a server error that omits the body), or the runtime/transport yields `response.body === null`.","commonSituations":"Pointing the gzip tool at a URL that returns 204, a misconfigured endpoint, an authenticated redirect that lands on a no-content response, or a server that streams via a mechanism the fetch impl doesn't expose as a ReadableStream.","solutions":["Point the `data` argument at a URL that returns an actual body (200 with content).","Verify the URL in a browser/curl: `curl -i <url>` and confirm a non-empty body.","If the endpoint legitimately returns no content for some inputs, choose a URL/path that returns the file."],"exampleFix":"# before\nURL returns 'HTTP/1.1 204 No Content'\n# after\nuse a URL that returns the actual file bytes (200 OK with body)","handlingStrategy":"validation","validationCode":"// pre-check with a lightweight HEAD/GET that you control\nasync function hasBody(url: string): Promise<boolean> {\n  const r = await fetch(url, { method: 'GET' });\n  return r.body != null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await callGzipTool({ data: url });\n} catch (e) {\n  if (e instanceof Error && e.message === 'No response body') {\n    // pick a URL that returns a body\n  }\n}","preventionTips":["Point the tool at URLs that return a 200 with a body.","Avoid endpoints that return 204/HEAD-style responses.","Verify with `curl -i` that the response carries content."],"tags":["mcp","typescript","everything-server","network","fetch"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}