spacedriveapp/spacedrive · error

Failed to initialize core: error code ${result}

Error message

Failed to initialize core: error code ${result}

What it means

Thrown by the thumbstrip processor in core/src/ops/media/thumbstrip/processor.rs when the content_identity row referenced by entry.content_id exists (the earlier 'ContentIdentity not found' check passed) but its uuid column is NULL. The processor needs a stable content UUID to key and name generated thumbnail-strip variants, so it cannot proceed without it. It fails the whole Result for that entry rather than returning a ProcessorResult::failure.

Source

Thrown at apps/mobile/src/client/SpacedriveClient.ts:68

  private initialized = false;
  private subscriptionManager: SubscriptionManager;

  constructor() {
    super();
    this.transport = new ReactNativeTransport();
    this.subscriptionManager = new SubscriptionManager(this.transport);
  }

  /**
   * Initialize the embedded Spacedrive core.
   * @param deviceName Optional device name for identification
   */
  async initialize(deviceName?: string): Promise<void> {
    if (this.initialized) return;

    const result = await SDMobileCore.initialize(undefined, deviceName);
    if (result !== 0) {
      throw new Error(`Failed to initialize core: error code ${result}`);
    }

    this.initialized = true;
  }

  /**
   * Check if the core is initialized.
   */
  isInitialized(): boolean {
    return this.initialized;
  }

  /**
   * Set the current library context for queries.
   * @param emitEvent - Whether to emit library-changed event (default: true)
   */
  setCurrentLibrary(libraryId: string | null, emitEvent: boolean = true) {
    this.currentLibraryId = libraryId;

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Inspect the offending row: SELECT id, uuid FROM content_identity WHERE id = <entry.content_id> to confirm uuid is NULL.
  2. Backfill UUIDs for all NULL rows (one-off UPDATE ... SET uuid = gen_random_uuid() WHERE uuid IS NULL, or re-run the indexing/identity job that assigns them).
  3. Re-run the thumbstrip job for the affected entries after the backfill.
  4. Add a migration making content_identity.uuid NOT NULL so the invariant is enforced at write time.

Example fix

-- before (data state)
SELECT id, uuid FROM content_identity WHERE id = 42; -- uuid = NULL

-- after (backfill)
UPDATE content_identity SET uuid = gen_random_uuid() WHERE uuid IS NULL;
ALTER TABLE content_identity ALTER COLUMN uuid SET NOT NULL;
Defensive patterns

Strategy: validation

Validate before calling

// Before dispatching the thumbstrip job, confirm the identity row has a UUID.
use crate::infra::db::entities::content_identity;
use sea_orm::{ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter};

async fn has_content_uuid(db: &DatabaseConnection, content_id: i32) -> Result<bool> {
    Ok(content_identity::Entity::find()
        .filter(content_identity::Column::Id.eq(content_id))
        .filter(content_identity::Column::Uuid.is_not_null())
        .one(db)
        .await?
        .is_some())
}

Try / catch

// In batch processing, catch per-entry and continue instead of failing the job.
match processor.process(entry.clone(), db).await {
    Ok(res) => results.push(res),
    Err(e) if e.to_string().contains("ContentIdentity missing UUID") => {
        tracing::warn!(entry_id = entry.id, "skipping: identity UUID missing, needs backfill");
        results.push(ProcessorResult::failure(e.to_string()));
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A thumbstrip/media-processing job runs over a video entry whose entry.content_id points at a content_identity row with uuid = NULL. The lookup at processor.rs:113-119 succeeds, then ci.uuid evaluates to None and the ok_or_else fires.

Common situations: Databases migrated from an older schema where content_identity.uuid was not yet populated; an interrupted identity-assignment/indexing job that created rows before assigning UUIDs; manual DB edits or imports that inserted NULL uuids.

Related errors


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