{"record":{"id":"06332fa409a0e1f5","repo":"gitroomhq/postiz-app","slug":"the-media-storage-did-not-return-the-requested-byt-06332f","errorCode":null,"errorMessage":"The media storage did not return the requested byte range, please try again","messagePattern":"The media storage did not return the requested byte range, please try again","errorType":"exception","errorClass":"BadBody","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts","lineNumber":480,"sourceCode":"    if (path.indexOf('http') === 0) {\n      // identity encoding so the store keeps content-length and can answer\n      // with the requested range: a transformed (compressed) response loses\n      // its length, and a length-less object is answered with the full body.\n      setHeartbeatDetails(\n        `youtube: read media ${start}-${end} ${stripQuery(path)}`\n      );\n      const response = await fetch(path, {\n        headers: {\n          Range: `bytes=${start}-${end}`,\n          'accept-encoding': 'identity',\n        },\n        dispatcher: getSsrfSafeDispatcher(),\n      } as any);\n\n      // A store that ignores Range (200 with the full file) or answers with an\n      // error page would corrupt the upload at this offset.\n      if (response.status !== 206) {\n        throw new BadBody(\n          this.identifier,\n          '{}',\n          '{}',\n          'The media storage did not return the requested byte range, please try again'\n        );\n      }\n\n      return response.body;\n    }\n\n    return createReadStream(path, { start, end });\n  }\n\n  // Asks the upload session for the truth: the created video when the upload\n  // completed, or the exact byte offset to resume from. We use the global fetch\n  // because the probe answers with 308 (Resume Incomplete), which this.fetch\n  // would treat as an error.\n  private async probeUploadSession(","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts#L462-L498","documentation":"The YouTube provider fetches a byte range of the stored video (Range: bytes=X-Y) for resumable chunked upload. It requires the storage to answer HTTP 206 Partial Content; any other status (200 full file, 403, 404, HTML error page) means the bytes written at the current offset would corrupt the upload, so it throws BadBody.","triggerScenarios":"Video upload chunking where the storage ignores Range requests and returns 200 with the entire file, or the signed URL expired/has wrong permissions and returns 4xx with an error body instead of the requested range.","commonSituations":"S3-compatible stores or proxies that don't support range requests; MinIO/nginx misconfiguration stripping Range headers; expired pre-signed media URLs; CDN caching a full-file 200 response.","solutions":["Check that the media URL supports range requests: curl -H 'Range: bytes=0-1023' -o /dev/null -w '%{http_code}' <url> should print 206","Fix proxy/CDN config to forward Range headers and return 206","Regenerate/re-upload the media so a fresh signed URL is used, then retry the post","If storage cannot support ranges, upload smaller media that fits a single chunk or fix the storage backend"],"exampleFix":"// before\nif (response.status !== 206) { throw new BadBody(...); }\n\n// after (no library change needed; verify storage)\n// curl -H 'Range: bytes=0-1023' -w '%{http_code}' https://media-url -> must be 206\nconst ok = response.status === 206;\nif (!ok) { throw new BadBody(this.identifier, '{}', '{}', 'The media storage did not return the requested byte range, please try again'); }","handlingStrategy":"validation","validationCode":"const r = await fetch(url, { headers: { Range: 'bytes=0-1023' } });\nif (r.status !== 206) throw new Error('Storage does not honor Range requests');","typeGuard":"const supportsRange = async (url: string) => (await fetch(url, { headers: { Range: 'bytes=0-0' } })).status === 206;","tryCatchPattern":"catch (e) { if (/did not return the requested byte range/.test(e.message)) { await refreshMediaUrl(); retryPost(); } throw e; }","preventionTips":["Health-check storage for 206 support during deployment","Use S3-compatible backends with range request support","Keep signed URL TTLs longer than post scheduling delays"],"tags":["youtube","range-request","http-206","storage","chunked-upload"],"backgroundTag":"range-request-not-honored","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}