{"record":{"id":"22e91dfe658bcac9","repo":"immich-app/immich","slug":"sidecar-files-cannot-be-deleted","errorCode":null,"errorMessage":"Sidecar files cannot be deleted","messagePattern":"Sidecar files cannot be deleted","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"server/src/services/asset-file.service.ts","lineNumber":42,"sourceCode":"  async download(auth: AuthDto, id: string) {\n    await this.requireAccess({ auth, permission: Permission.AssetFileDownload, ids: [id] });\n    const file = await findOrFail(() => this.assetFileRepository.get(id), 'Asset file');\n\n    return new ImmichFileResponse({\n      path: file.path,\n      fileName: getFileNameWithoutExtension(file.path) + getFilenameExtension(file.path),\n      contentType: mimeTypes.lookup(file.path),\n      cacheControl: CacheControl.PrivateWithCache,\n    });\n  }\n\n  async delete(auth: AuthDto, id: string) {\n    await this.requireAccess({ auth, permission: Permission.AssetFileDelete, ids: [id] });\n\n    const file = await findOrFail(() => this.assetFileRepository.get(id), 'Asset file');\n    // TODO consider implications of allowing sidecar files to be deleted\n    if (file.type === AssetFileType.Sidecar) {\n      throw new BadRequestException('Sidecar files cannot be deleted');\n    }\n\n    await this.assetFileRepository.delete(id);\n    await this.jobRepository.queue({ name: JobName.FileDelete, data: { files: [file.path] } });\n  }\n}\n","sourceCodeStart":24,"sourceCodeEnd":49,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/asset-file.service.ts#L24-L49","documentation":"Raised by AssetFileService.delete when the target file record represents a sidecar (e.g. XMP metadata) file rather than a primary asset file. Sidecars are managed automatically alongside their parent asset, so direct deletion through this endpoint is blocked; the offending input is the asset file id.","triggerScenarios":"Thrown at server/src/services/asset-file.service.ts:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the parent asset instead, which removes its sidecars as part of asset deletion","Let Immich regenerate/drop sidecars via its metadata workflows rather than deleting the file record directly"],"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"}