spacedriveapp/spacedrive · error
Library with ID '${libraryId}' not found
Error message
Library with ID '${libraryId}' not found What it means
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.
Source
Thrown at packages/ts-client/src/client.ts:144
this.currentLibraryId = null;
}
/**
* Switch to a library by ID
* Verifies the library exists before switching
*/
async switchToLibrary(libraryId: string): Promise<void> {
// Verify library exists by calling the query directly
const libraries = await this.execute<{}, any[]>(
"query:libraries.list",
{},
);
const libraryExists = libraries.some(
(lib: any) => lib.id === libraryId,
);
if (!libraryExists) {
throw new Error(`Library with ID '${libraryId}' not found`);
}
this.setCurrentLibrary(libraryId);
}
/**
* Get information about the currently active library
*/
async getCurrentLibraryInfo() {
const libraryId = this.getCurrentLibraryId();
if (!libraryId) return null;
const libraries = await this.execute<{}, any[]>(
"query:libraries.list",
{},
);
return libraries.find((lib: any) => lib.id === libraryId) ?? null;
}View on GitHub (pinned to 6dfeccf211)
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.
Defensive patterns
Strategy: validation
Validate before calling
async fn entry_exists(db: &DatabaseConnection, id: i32) -> Result<bool> {
Ok(entry::Entity::find_by_id(id).one(db).await?.is_some())
}
if !entry_exists(db, target_entry_id).await? {
return Err(anyhow::anyhow!("target entry {} no longer exists, re-index it", target_entry_id));
} Try / catch
match svc.create_conduit(src, tgt, mode, sched).await {
Ok(c) => Ok(c),
Err(e) if e.to_string().contains("Target entry not found") => {
Err(refresh_target_hint(tgt))
}
Err(e) => Err(e),
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- This operation requires an active library. Use switchToLibra
- Unexpected response: ${JSON.stringify(response)}
- No library selected. Use client.switchToLibrary() first.
- No library selected. Use client.switchToLibrary() first.
- RPC ${response.status} ${response.statusText}${text ? `: ${t
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/f025af2ea3b4b0a3.
Report an issue: GitHub.