spacedriveapp/spacedrive · error

ContentIdentity not found

Error message

ContentIdentity not found

What it means

After OCR extracts text, the processor loads the content_identity row by the entry's content_id to write text_content. This error means that row no longer exists: the content identity was deleted (or its entry re-identified and replaced) between when the processor was scheduled and when it ran.

Source

Thrown at core/src/ops/media/ocr/processor.rs:95

		debug!("→ Extracting text via OCR for: {}", entry.path.display());

		// Extract text
		let extracted_text = super::extract_text_from_file(&entry.path, &self.languages).await?;

		if extracted_text.is_empty() {
			debug!("No text extracted from: {}", entry.path.display());
			return Ok(ProcessorResult::success(0, 0));
		}

		debug!("✓ Extracted {} characters of text", extracted_text.len());

		// Update content_identity with extracted text
		use crate::infra::db::entities::content_identity;

		let ci = content_identity::Entity::find_by_id(content_id)
			.one(db)
			.await?
			.ok_or_else(|| anyhow::anyhow!("ContentIdentity not found"))?;

		let mut ci_active: content_identity::ActiveModel = ci.into();
		ci_active.text_content = Set(Some(extracted_text.clone()));

		ci_active.update(db).await?;

		debug!("✓ Stored extracted text in content_identity");

		Ok(ProcessorResult::success(1, extracted_text.len() as u64))
	}

	pub fn name(&self) -> &'static str {
		"ocr"
	}
}

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Treat the missing row as a skip (ProcessorResult::success(0, 0) or a skipped status), not a hard error
  2. Cancel queued OCR jobs when their entries are deleted or re-identified
  3. Re-run identification then OCR if the file still exists
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the identity row still exists before OCR
current = content_identity::Entity::find_by_id(content_id).one(db).await?;
if current.is_none() { /* skip: entry was re-identified or deleted */ }

Try / catch

match content_identity::Entity::find_by_id(content_id).one(db).await? {
    Some(ci) => { /* proceed with update */ }
    None => {
        tracing::debug!(%content_id, "content identity vanished; skipping OCR write");
        return Ok(ProcessorResult::success(0, 0));
    }
}

Prevention

When it happens

Trigger: Entry deleted or re-indexed while the OCR job sat in queue, cascading deletion of content_identity; re-identification creating a new content row and removing the old one; manual DB cleanup.

Common situations: Long processor backlogs with active file deletion; reindex runs that rebuild content identities; multi-client libraries where another client purges content.

Related errors


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