{"record":{"id":"0589e18b6f887bd9","repo":"immich-app/immich","slug":"library-id-not-found","errorCode":null,"errorMessage":"Library ${id} not found","messagePattern":"Library (.+?) not found","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"server/src/services/library.service.ts","lineNumber":202,"sourceCode":"      await this.unwatch(id);\n    }\n  }\n\n  async watchAll() {\n    if (!this.lock) {\n      return false;\n    }\n\n    const libraries = await this.libraryRepository.getAll(false);\n    for (const library of libraries) {\n      await this.watch(library.id);\n    }\n  }\n\n  async getStatistics(id: string): Promise<LibraryStatsResponseDto> {\n    const statistics = await this.libraryRepository.getStatistics(id);\n    if (!statistics) {\n      throw new BadRequestException(`Library ${id} not found`);\n    }\n    return statistics;\n  }\n\n  async get(id: string): Promise<LibraryResponseDto> {\n    const library = await this.findOrFail(id);\n    return mapLibrary(library);\n  }\n\n  async getAll(): Promise<LibraryResponseDto[]> {\n    const libraries = await this.libraryRepository.getAll(false);\n    return libraries.map((library) => mapLibrary(library));\n  }\n\n  @OnJob({ name: JobName.LibraryDeleteCheck, queue: QueueName.Library })\n  async handleQueueCleanup(): Promise<JobStatus> {\n    this.logger.log('Checking for any libraries pending deletion...');\n    const pendingDeletions = await this.libraryRepository.getAllDeleted();","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/library.service.ts#L184-L220","documentation":"getStatistics looks up aggregate statistics for a library via libraryRepository.getStatistics; when the repository returns no row the requested library id does not exist (or has no computable statistics), so the method converts the missing result into a 400 BadRequestException instead of returning an empty/undefined DTO. It is an existence guard on the id path parameter, not a data-format failure.","triggerScenarios":"Thrown at server/src/services/library.service.ts:202 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the library id from the request actually exists (GET /libraries) before requesting statistics","Handle the 400 response on the client by showing 'library not found' and refreshing the library list","If the library was recently deleted, re-fetch collections to purge stale ids from the client state"],"exampleFix":null,"handlingStrategy":"validation","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"}