{"record":{"id":"f025af2ea3b4b0a3","repo":"spacedriveapp/spacedrive","slug":"library-with-id-libraryid-not-found","errorCode":null,"errorMessage":"Library with ID '${libraryId}' not found","messagePattern":"Library with ID '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ts-client/src/client.ts","lineNumber":144,"sourceCode":"\t\tthis.currentLibraryId = null;\n\t}\n\n\t/**\n\t * Switch to a library by ID\n\t * Verifies the library exists before switching\n\t */\n\tasync switchToLibrary(libraryId: string): Promise<void> {\n\t\t// Verify library exists by calling the query directly\n\t\tconst libraries = await this.execute<{}, any[]>(\n\t\t\t\"query:libraries.list\",\n\t\t\t{},\n\t\t);\n\t\tconst libraryExists = libraries.some(\n\t\t\t(lib: any) => lib.id === libraryId,\n\t\t);\n\n\t\tif (!libraryExists) {\n\t\t\tthrow new Error(`Library with ID '${libraryId}' not found`);\n\t\t}\n\n\t\tthis.setCurrentLibrary(libraryId);\n\t}\n\n\t/**\n\t * Get information about the currently active library\n\t */\n\tasync getCurrentLibraryInfo() {\n\t\tconst libraryId = this.getCurrentLibraryId();\n\t\tif (!libraryId) return null;\n\n\t\tconst libraries = await this.execute<{}, any[]>(\n\t\t\t\"query:libraries.list\",\n\t\t\t{},\n\t\t);\n\t\treturn libraries.find((lib: any) => lib.id === libraryId) ?? null;\n\t}","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/packages/ts-client/src/client.ts#L126-L162","documentation":"Returned by FileSyncService::create_conduit when the source entry exists but entry::Entity::find_by_id(target_entry_id) returns no row. It is the mirror of the 'Source entry not found' check and fires only after the source lookup succeeded, so seeing this error confirms the source ID was valid.","triggerScenarios":"Calling create_conduit with a target_entry_id that does not exist in the entries table — deleted target directory, ID from a different library, or a typo/stale client value.","commonSituations":"Target directory deleted or moved between selection and submission; UI caching stale entry IDs across a reindex; syncing against a library whose database was swapped or restored from backup.","solutions":["Verify the ID: SELECT id, kind FROM entry WHERE id = <target_entry_id> in the same library database.","Re-index the target location if the directory still exists on disk, then use the fresh entry ID.","Refresh the client's entry list before conduit creation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async fn entry_exists(db: &DatabaseConnection, id: i32) -> Result<bool> {\n    Ok(entry::Entity::find_by_id(id).one(db).await?.is_some())\n}\n\nif !entry_exists(db, target_entry_id).await? {\n    return Err(anyhow::anyhow!(\"target entry {} no longer exists, re-index it\", target_entry_id));\n}","typeGuard":null,"tryCatchPattern":"match svc.create_conduit(src, tgt, mode, sched).await {\n    Ok(c) => Ok(c),\n    Err(e) if e.to_string().contains(\"Target entry not found\") => {\n        Err(refresh_target_hint(tgt))\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Validate both endpoint IDs client-side before submit; the target check only runs if the source passed.","Avoid persisting entry IDs across sessions — re-resolve paths to current IDs.","Watch for reindex events that delete target entries and invalidate open forms."],"tags":["rust","database","file-sync","validation"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}