spacedriveapp/spacedrive · error

Location {} has no root entry

Error message

Location {} has no root entry

What it means

The location row exists but its entry_id column is NULL, so DatabaseAdapter::new cannot learn the root entry that anchors the entry closure tree. Locations get entry_id only after the initial indexer creates the root entry; a NULL means that initialization never completed or was interrupted, and path-to-entry resolution would have no root to descend from.

Source

Thrown at core/src/ops/indexing/change_detection/persistent.rs:64

		_location_root: &Path,
		volume_backend: Option<Arc<dyn crate::volume::VolumeBackend>>,
	) -> Result<Self> {
		let library = context
			.get_library(library_id)
			.await
			.ok_or_else(|| anyhow::anyhow!("Library not found: {}", library_id))?;

		let db = library.db().conn().clone();

		let location_record = entities::location::Entity::find()
			.filter(entities::location::Column::Uuid.eq(location_id))
			.one(&db)
			.await?
			.ok_or_else(|| anyhow::anyhow!("Location not found: {}", location_id))?;

		let location_root_entry_id = location_record
			.entry_id
			.ok_or_else(|| anyhow::anyhow!("Location {} has no root entry", location_id))?;

		let volume_id = location_record.volume_id.ok_or_else(|| {
			anyhow::anyhow!(
				"Location {} has no volume_id - volume must be detected before change detection",
				location_id
			)
		})?;

		Ok(Self {
			context,
			library_id,
			location_id,
			location_root_entry_id,
			volume_id,
			db,
			volume_backend,
			entry_id_cache: HashMap::new(),
		})

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Run the initial indexer for the location (it creates the root entry and sets entry_id) before enabling change detection
  2. Check location creation code to confirm it writes entry_id after creating the root entry
  3. If migrating, backfill entry_id for existing locations from their root entry rows
Defensive patterns

Strategy: validation

Validate before calling

// Require a rooted location before starting change detection
let loc = entities::location::Entity::find()
    .filter(entities::location::Column::Uuid.eq(location_id))
    .one(&db).await?;
match loc {
    Some(l) if l.entry_id.is_some() => { /* safe to construct DatabaseAdapter */ }
    _ => { /* run initial indexer first, then retry */ }
}

Try / catch

if let Err(e) = DatabaseAdapter::new(...).await {
    if e.to_string().contains("has no root entry") {
        // trigger initial index for this location, then re-queue change detection
    }
}

Prevention

When it happens

Trigger: Starting persistent change detection on a location whose initial index never ran or crashed before creating the root entry; restoring a database dump from before the root-entry backfill; location creation flow interrupted between INSERT and root entry creation.

Common situations: Daemon killed during first index of a new location; location added but indexer job failed early; schema migration that added entry_id without backfilling existing rows.

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/9dfaed3966dc6500. Report an issue: GitHub.