{"record":{"id":"ad5d1dbe6e1e338d","repo":"remotion-dev/remotion","slug":"no-stream-with-the-id-selectedstreamid-found","errorCode":null,"errorMessage":"No stream with the id ${selectedStreamId} found","messagePattern":"No stream with the id (.+?) found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/m3u/select-stream.ts","lineNumber":81,"sourceCode":"\nexport const selectStream = async ({\n\tstreams,\n\tfn,\n}: {\n\tstreams: M3uStream[];\n\tfn: SelectM3uStreamFn;\n}): Promise<M3uStream> => {\n\tif (streams.length < 1) {\n\t\tthrow new Error('No streams found');\n\t}\n\n\tconst selectedStreamId = await fn({streams});\n\tconst selectedStream = streams.find(\n\t\t(stream) => stream.id === selectedStreamId,\n\t);\n\n\tif (!selectedStream) {\n\t\tthrow new Error(`No stream with the id ${selectedStreamId} found`);\n\t}\n\n\treturn Promise.resolve(selectedStream);\n};\n\nexport const defaultSelectM3uStreamFn: SelectM3uStreamFn = ({streams}) => {\n\treturn Promise.resolve(streams[0].id);\n};\n","sourceCodeStart":63,"sourceCodeEnd":90,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/m3u/select-stream.ts#L63-L90","documentation":"Thrown by `selectStream` when the custom `selectM3uStream` callback returns an `id` that does not match any `M3uStream` in the `streams` array. The callback must return a numeric `id` corresponding to one of the offered streams.","triggerScenarios":"Providing a custom `selectM3uStream` option to `parseMedia()` that returns an `id` not present among the `streams[i].id` values. The lookup `streams.find((stream) => stream.id === selectedStreamId)` returns `undefined`.","commonSituations":"A callback that returns a hardcoded `id` (e.g., `return 0`) when stream IDs don't start at 0. Returning an index instead of an `id`. Returning `id` from a stale or different manifest. Off-by-one errors between stream index and stream id.","solutions":["Return the `id` property of a stream that exists in the `streams` array passed to your callback.","Select by finding the desired stream first: `return streams.find(s => s.bandwidth > 1000000).id`.","Use the default `defaultSelectM3uStreamFn` which returns `streams[0].id` if you just want the first stream.","Log `streams.map(s => s.id)` in your callback to verify valid IDs before returning one."],"exampleFix":"// before\nselectM3uStream: ({streams}) => {\n  return 0; // might not be a valid id\n}\n\n// after\nselectM3uStream: ({streams}) => {\n  return streams[0].id;\n}","handlingStrategy":"validation","validationCode":"// Validate the returned id before it is used\nimport type {SelectM3uStreamFn} from '@remotion/media-parser';\n\nconst safeSelect: SelectM3uStreamFn = ({streams}) => {\n  const id = myCustomSelect(streams);\n  if (!streams.some((s) => s.id === id)) {\n    throw new Error(`Invalid stream id ${id}. Valid: ${streams.map((s) => s.id).join(', ')}`);\n  }\n  return id;\n};","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src, selectM3uStream: myFn});\n} catch (e) {\n  if (e instanceof Error && e.message.includes('No stream with the id')) {\n    console.error('Your selectM3uStream callback returned an invalid id.');\n  }\n  throw e;\n}","preventionTips":["Always return the .id property of a stream from the streams array you received.","Do not return a hardcoded index; stream ids may not start at 0.","Use streams.find(condition).id rather than guessing ids.","Use the default callback (streams[0].id) if you just want the first stream."],"tags":["hls","m3u8","callback-contract","select-stream","id-mismatch"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}