{"record":{"id":"ead4a0d556938cfb","repo":"spacedriveapp/spacedrive","slug":"failed-to-initialize-core-error-code-result","errorCode":null,"errorMessage":"Failed to initialize core: error code ${result}","messagePattern":"Failed to initialize core: error code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/mobile/src/client/SpacedriveClient.ts","lineNumber":68,"sourceCode":"  private initialized = false;\n  private subscriptionManager: SubscriptionManager;\n\n  constructor() {\n    super();\n    this.transport = new ReactNativeTransport();\n    this.subscriptionManager = new SubscriptionManager(this.transport);\n  }\n\n  /**\n   * Initialize the embedded Spacedrive core.\n   * @param deviceName Optional device name for identification\n   */\n  async initialize(deviceName?: string): Promise<void> {\n    if (this.initialized) return;\n\n    const result = await SDMobileCore.initialize(undefined, deviceName);\n    if (result !== 0) {\n      throw new Error(`Failed to initialize core: error code ${result}`);\n    }\n\n    this.initialized = true;\n  }\n\n  /**\n   * Check if the core is initialized.\n   */\n  isInitialized(): boolean {\n    return this.initialized;\n  }\n\n  /**\n   * Set the current library context for queries.\n   * @param emitEvent - Whether to emit library-changed event (default: true)\n   */\n  setCurrentLibrary(libraryId: string | null, emitEvent: boolean = true) {\n    this.currentLibraryId = libraryId;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/mobile/src/client/SpacedriveClient.ts#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the offending row: SELECT id, uuid FROM content_identity WHERE id = <entry.content_id> to confirm uuid is NULL.","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).","Re-run the thumbstrip job for the affected entries after the backfill.","Add a migration making content_identity.uuid NOT NULL so the invariant is enforced at write time."],"exampleFix":"-- before (data state)\nSELECT id, uuid FROM content_identity WHERE id = 42; -- uuid = NULL\n\n-- after (backfill)\nUPDATE content_identity SET uuid = gen_random_uuid() WHERE uuid IS NULL;\nALTER TABLE content_identity ALTER COLUMN uuid SET NOT NULL;","handlingStrategy":"validation","validationCode":"// Before dispatching the thumbstrip job, confirm the identity row has a UUID.\nuse crate::infra::db::entities::content_identity;\nuse sea_orm::{ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter};\n\nasync fn has_content_uuid(db: &DatabaseConnection, content_id: i32) -> Result<bool> {\n    Ok(content_identity::Entity::find()\n        .filter(content_identity::Column::Id.eq(content_id))\n        .filter(content_identity::Column::Uuid.is_not_null())\n        .one(db)\n        .await?\n        .is_some())\n}","typeGuard":null,"tryCatchPattern":"// In batch processing, catch per-entry and continue instead of failing the job.\nmatch processor.process(entry.clone(), db).await {\n    Ok(res) => results.push(res),\n    Err(e) if e.to_string().contains(\"ContentIdentity missing UUID\") => {\n        tracing::warn!(entry_id = entry.id, \"skipping: identity UUID missing, needs backfill\");\n        results.push(ProcessorResult::failure(e.to_string()));\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Add a NOT NULL constraint on content_identity.uuid via migration so bad rows cannot be written.","Run a backfill migration for existing NULL uuid rows before upgrading media-processing code.","Log entry.id alongside the error so the offending row is identifiable without a debugger."],"tags":["rust","database","media-processing","thumbstrip","data-integrity"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}