{"record":{"id":"86b2ce6f29999844","repo":"remotion-dev/remotion","slug":"range-header-requestedrange-does-not-match-co","errorCode":null,"errorMessage":"Range header (${requestedRange}) does not match content-range header (${parsedContentRange?.start})","messagePattern":"Range header \\((.+?)\\) does not match content-range header \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/readers/from-fetch.ts","lineNumber":67,"sourceCode":"\tstatusCode,\n}: {\n\trequestedRange: number | [number, number];\n\tparsedContentRange: ParsedContentRange | null;\n\tstatusCode: number;\n}): {supportsContentRange: boolean} => {\n\tif (statusCode === 206) {\n\t\treturn {supportsContentRange: true};\n\t}\n\n\tif (\n\t\ttypeof requestedRange === 'number' &&\n\t\tparsedContentRange?.start !== requestedRange\n\t) {\n\t\tif (requestedRange === 0) {\n\t\t\treturn {supportsContentRange: false};\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`Range header (${requestedRange}) does not match content-range header (${parsedContentRange?.start})`,\n\t\t);\n\t}\n\n\tif (\n\t\trequestedRange !== null &&\n\t\ttypeof requestedRange !== 'number' &&\n\t\t(parsedContentRange?.start !== requestedRange[0] ||\n\t\t\tparsedContentRange?.end !== requestedRange[1])\n\t) {\n\t\tthrow new Error(\n\t\t\t`Range header (${requestedRange}) does not match content-range header (${parsedContentRange?.start})`,\n\t\t);\n\t}\n\n\treturn {supportsContentRange: true};\n};\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/readers/from-fetch.ts#L49-L85","documentation":"validateContentRangeAndDetectIfSupported handles the numeric-range branch: when a number was requested, status is not 206, and parsedContentRange.start !== requestedRange, it throws unless requestedRange === 0 (which is treated as 'range not supported, serve everything'). The server's Content-Range start must match the byte offset the parser asked for.","triggerScenarios":"The parser requested `Range: bytes=N-` (N>0) and the server returned a Content-Range starting at a different offset (e.g. always 0, or a clamped/wrong start) with a 200-ish status. Indicates the server ignored or mis-answered the Range request.","commonSituations":"CDNs that clamp ranges, servers that always return the full file with a stale Content-Range header, load balancers rewriting ranges, or caches keyed incorrectly returning the wrong byte slice.","solutions":["Ensure the server/CDN correctly implements Range: respond 206 with Content-Range: bytes N-M/T matching the requested start.","Test with curl: `curl -v -r 1000-2000 <url>` and confirm Content-Range starts at 1000.","Disable any transform/compression that breaks range fidelity for media MIME types.","Move the asset to a Range-compliant host (S3, R2, static CDN) if the origin cannot be fixed."],"exampleFix":"// before: origin ignores Range start\nres.set('Content-Range', `bytes 0-${end}/${total}`); // always 0\n\n// after: honor requested start\nres.status(206)\n  .set('Content-Range', `bytes ${start}-${end}/${total}`)\n  .set('Content-Length', String(end - start + 1));\nfs.createReadStream(file, {start, end}).pipe(res);","handlingStrategy":"validation","validationCode":"// Verify Content-Range start matches the requested numeric offset\nconst r = await fetch(url, {headers: {Range: 'bytes=1000-'}});\nconst cr = r.headers.get('content-range'); // expect 'bytes 1000-.../...'\nif (r.status !== 206 || !cr || !cr.startsWith('bytes 1000-')) {\n  throw new Error('Server did not honor numeric Range start');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src: url, fields: {durationInSeconds: true}});\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not match content-range')) {\n    throw new Error('Origin Range compliance issue (numeric start mismatch)');\n  }\n  throw e;\n}","preventionTips":["Make origins 206 with a Content-Range start equal to the requested offset.","Test with curl -v -r <start>- <url> and inspect Content-Range.","Disable range-mangling middleware/CDN features for media.","Use Range-compliant object storage for media hosting."],"tags":["network","http-range","content-range","cdn","media-parser"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}