{"record":{"id":"388fb9729d314425","repo":"spacedriveapp/spacedrive","slug":"failed-to-add-entry-to-ephemeral-index","errorCode":null,"errorMessage":"Failed to add entry to ephemeral index: {}","messagePattern":"Failed to add entry to ephemeral index: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/src/ops/indexing/ephemeral/writer.rs","lineNumber":71,"sourceCode":"\t\t}\n\t}\n\n\tfn next_id(&self) -> i32 {\n\t\tself.next_id.fetch_add(1, Ordering::SeqCst)\n\t}\n\n\t/// Core write operation shared by both watcher and indexer pipelines.\n\tasync fn add_entry_internal(\n\t\t&self,\n\t\tpath: &Path,\n\t\tuuid: Uuid,\n\t\tmetadata: EntryMetadata,\n\t) -> Result<(i32, Option<crate::domain::ContentKind>)> {\n\t\tlet content_kind = {\n\t\t\tlet mut index = self.index.write().await;\n\t\t\tindex\n\t\t\t\t.add_entry(path.to_path_buf(), uuid, metadata.clone())\n\t\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to add entry to ephemeral index: {}\", e))?\n\t\t};\n\n\t\tlet entry_id = self.next_id();\n\t\tOk((entry_id, content_kind))\n\t}\n\n\tasync fn emit_resource_changed(\n\t\t&self,\n\t\tuuid: Uuid,\n\t\tpath: &Path,\n\t\tmetadata: &EntryMetadata,\n\t\tcontent_kind: crate::domain::ContentKind,\n\t) {\n\t\tuse crate::device::get_current_device_slug;\n\t\tuse crate::domain::addressing::SdPath;\n\t\tuse crate::domain::file::File;\n\t\tuse crate::infra::event::{Event, ResourceMetadata};\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/ops/indexing/ephemeral/writer.rs#L53-L89","documentation":"The ephemeral index writer's add_entry_internal locks the in-memory index and calls index.add_entry; any failure there (duplicate path already interned, arena allocation error, invalid name/parent combination) is wrapped with this message. The write lock is held during the call, so this is a structural index error rather than an I/O error.","triggerScenarios":"Watcher and indexer pipelines inserting the same path concurrently in a way that double-adds; adding an entry whose parent name is not yet interned; arena capacity or allocation limits hit on very large ephemeral scans.","commonSituations":"Duplicate filesystem events for one create; ephemeral cache used across restarts with stale interning state; extremely large directories exhausting arena capacity.","solutions":["Read the wrapped inner error: 'already present' means the event was duplicated and can be treated as an update instead","Deduplicate watcher events before they reach the writer","Ensure parent directories are added before children (ordered walks)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match index.add_entry(path.to_path_buf(), uuid, metadata.clone()) {\n    Ok(kind) => kind,\n    Err(e) if e.to_string().contains(\"already\") => {\n        // duplicate event: fall through to update semantics\n        index.update_entry(path, metadata)?\n    }\n    Err(e) => return Err(anyhow::anyhow!(\"Failed to add entry to ephemeral index: {}\", e)),\n}","preventionTips":["Deduplicate watcher events per path before they reach the writer","Insert parent directories before children (ordered directory walks)","Log the offending path on add failures to spot systematic duplicates"],"tags":["ephemeral-index","indexing","watcher","duplicate-events"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}