{"record":{"id":"d6cb3b623718fa6f","repo":"immich-app/immich","slug":"session-not-found","errorCode":null,"errorMessage":"Session not found","messagePattern":"Session not found","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server/src/services/hls.service.ts","lineNumber":96,"sourceCode":"    const hintedSegment = position === undefined ? undefined : this.positionToSegmentIndex(segmentation, position);\n    this.prewarmVariant(assetId, sessionId, variantIndex, hintedSegment);\n\n    return this.generateMediaPlaylist(asset, segmentation);\n  }\n\n  async getSegment(\n    auth: AuthDto,\n    assetId: string,\n    sessionId: string,\n    variantIndex: number,\n    filename: string,\n    initSegment?: number,\n  ) {\n    await this.requireAccess({ auth, permission: Permission.AssetView, ids: [assetId] });\n\n    const session = await this.videoStreamRepository.getSession(sessionId);\n    if (!session) {\n      throw new NotFoundException('Session not found');\n    }\n\n    const variantDir = StorageCore.getHlsVariantFolder({ ownerId: auth.user.id, sessionId, variantIndex });\n    const path = join(variantDir, filename);\n    const response = new ImmichFileResponse({\n      path,\n      contentType: 'video/mp4',\n      cacheControl: CacheControl.PrivateWithCache,\n    });\n\n    const apiSession = this.trackSession(sessionId, variantIndex);\n    const segmentIndex = this.getSegmentIndex(apiSession, filename, initSegment);\n    this.websocketRepository.serverSend('HlsHeartbeat', { sessionId, variantIndex, segmentIndex });\n\n    if (await this.storageRepository.checkFileExists(path, constants.R_OK)) {\n      return response;\n    }\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/hls.service.ts#L78-L114","documentation":"Guard in getSegment: the requested HLS session id has no entry in the video stream session table. Sessions are created by the owning transcoding worker and expire or are removed when transcoding stops, so a stale or unknown session id (expired playback, worker restart, forged id) yields a 404 before serving the segment.","triggerScenarios":"Thrown at server/src/services/hls.service.ts:96 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Let the player restart playback from the main playlist to obtain a fresh session","Verify the sessionId came from a recent getMainPlaylist/getMediaPlaylist response","Ensure the transcoding worker and session store share state and cleanup timing","Reject stale sessions client-side and re-request the stream"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}