{"record":{"id":"e6eab18129721b02","repo":"remotion-dev/remotion","slug":"value-is-null-e6eab1","errorCode":null,"errorMessage":"Value is null","messagePattern":"Value is null","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/m3u/parse-stream-inf.ts","lineNumber":42,"sourceCode":"\n\t// Push the last token, if any.\n\tif (currentPart) {\n\t\tresult.push(currentPart);\n\t}\n\n\treturn result;\n}\n\nexport const parseStreamInf = (str: string): M3uStreamInfo => {\n\tconst quotes = splitRespectingQuotes(str);\n\tconst map: Record<string, string> = {};\n\tfor (const quote of quotes) {\n\t\tconst firstColon = quote.indexOf('=');\n\t\tconst key =\n\t\t\tfirstColon === -1 ? quote : (quote.slice(0, firstColon) as string);\n\t\tconst value = firstColon === -1 ? null : quote.slice(firstColon + 1);\n\t\tif (value === null) {\n\t\t\tthrow new Error('Value is null');\n\t\t}\n\n\t\tconst actualValue =\n\t\t\tvalue?.startsWith('\"') && value?.endsWith('\"')\n\t\t\t\t? value.slice(1, -1)\n\t\t\t\t: value;\n\n\t\tmap[key] = actualValue;\n\t}\n\n\treturn {\n\t\ttype: 'm3u-stream-info',\n\t\taverageBandwidthInBitsPerSec: map['AVERAGE-BANDWIDTH']\n\t\t\t? parseInt(map['AVERAGE-BANDWIDTH'], 10)\n\t\t\t: null,\n\t\tbandwidthInBitsPerSec: map.BANDWIDTH ? parseInt(map.BANDWIDTH, 10) : null,\n\t\tcodecs: map.CODECS ? map.CODECS.split(',') : null,\n\t\tdimensions: map.RESOLUTION","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/m3u/parse-stream-inf.ts#L24-L60","documentation":"Thrown by `parseStreamInf` while parsing the attributes of an HLS `#EXT-X-STREAM-INF` directive. Each comma-separated attribute must contain an `=` sign (key=value). When `splitRespectingQuotes` produces a token with no `=` (i.e., `firstColon === -1`), the value is `null` and the parser refuses to proceed.","triggerScenarios":"Parsing an HLS master playlist whose `#EXT-X-STREAM-INF` line contains a bare attribute token without an `=` sign — e.g., `#EXT-X-STREAM-INF:BANDWIDTH=1280000,UNQUOTED` where `UNQUOTED` has no value, or a manifest that uses non-standard attribute syntax.","commonSituations":"Hand-edited or dynamically generated M3U8 manifests with typos in stream-inf attributes. Third-party CDN manifests with non-conformant attribute formatting. Manifests produced by tools that emit attribute flags without values.","solutions":["Inspect the `#EXT-X-STREAM-INF` line in the manifest and ensure every attribute follows `KEY=VALUE` format.","If the manifest is served by a third party, report the malformed directive or proxy/fix the manifest before parsing.","Validate the manifest against the HLS specification (RFC 8216) before passing it to `parseMedia`.","Use a manifest validation tool or HLS conformance checker to catch syntax errors upstream."],"exampleFix":"// before (malformed manifest line)\n#EXT-X-STREAM-INF:BANDWIDTH=1280000,RESOLUTION\n\n// after\n#EXT-X-STREAM-INF:BANDWIDTH=1280000,RESOLUTION=1280x720","handlingStrategy":"try-catch","validationCode":"// Pre-validate an HLS manifest before parsing\nfunction validateStreamInf(manifestText: string): void {\n  const lines = manifestText.split('\\n');\n  for (const line of lines) {\n    if (line.startsWith('#EXT-X-STREAM-INF:')) {\n      const attrs = line.slice('#EXT-X-STREAM-INF:'.length);\n      const parts = attrs.split(',');\n      for (const part of parts) {\n        if (!part.includes('=') && !part.startsWith('\"')) {\n          throw new Error(`Malformed STREAM-INF attribute: \"${part}\" (missing '=')`);\n        }\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src: 'https://example.com/master.m3u8'});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Value is null') {\n    console.error('The HLS manifest has a malformed #EXT-X-STREAM-INF directive.');\n    // Inspect and fix the manifest source\n  }\n  throw e;\n}","preventionTips":["Validate HLS manifests against RFC 8216 before parsing.","Ensure all #EXT-X-STREAM-INF attributes use KEY=VALUE format.","Use an HLS conformance checker on manifests from third-party CDNs."],"tags":["hls","m3u8","manifest-parsing","malformed-input"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}