{"record":{"id":"3ec58dd5f21cec54","repo":"siyuan-note/siyuan","slug":"incompatible-encrypted-index","errorCode":null,"errorMessage":"incompatible encrypted index","messagePattern":"incompatible encrypted index","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/encrypted_index.go","lineNumber":62,"sourceCode":"\t\tif _, err = db.Exec(\"CREATE TABLE encrypted_index_meta (kind TEXT NOT NULL, schema_version INTEGER NOT NULL, cipher_settings TEXT NOT NULL)\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = db.Exec(\"INSERT INTO encrypted_index_meta VALUES (?, ?, ?)\", kind, schema, string(encoded))\n\t\treturn err\n\t}\n\tvar storedKind, storedSettings string\n\tvar storedSchema, rows int\n\tif err = db.QueryRow(\"SELECT count(*) FROM encrypted_index_meta\").Scan(&rows); err != nil {\n\t\treturn err\n\t}\n\tif rows != 1 {\n\t\treturn errors.New(\"invalid encrypted index compatibility metadata\")\n\t}\n\tif err = db.QueryRow(\"SELECT kind, schema_version, cipher_settings FROM encrypted_index_meta\").Scan(&storedKind, &storedSchema, &storedSettings); err != nil {\n\t\treturn err\n\t}\n\tif storedKind != kind || storedSchema != schema || storedSettings != string(encoded) {\n\t\treturn errors.New(\"incompatible encrypted index\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":44,"sourceCodeEnd":66,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/encrypted_index.go#L44-L66","documentation":"The stored compatibility metadata does not match what the current kernel expects: the index kind, schema version, or recorded cipher settings differ from the values computed for this open. This is a deliberate authentication gate — the index was built with a different schema or cipher configuration and must not be read until rebuilt from authenticated source documents.","triggerScenarios":"Opening an index whose schema_version or kind differs from the value passed by OpenEncryptedDB/OpenEncryptedBlockTreeDB, or whose recorded cipher PRAGMAs (kdf_iter, cipher_page_size, etc.) differ from the current settings — typically after a kernel upgrade that bumped the schema or a cipher parameter change.","commonSituations":"Downgrading the kernel after a schema bump; switching encryption settings (page size, KDF iterations); opening an index belonging to a different subsystem (wrong kind); a workspace synced between machines running different kernel versions.","solutions":["Rebuild the index from the authenticated source documents (the caller owns reindexing)","Upgrade or downgrade the kernel so kind/schema/cipher settings match the metadata","Restore the workspace from a sync snapshot taken with a matching kernel version","Do not edit encrypted_index_meta rows manually — the cipher settings must genuinely match"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// compare stored metadata with current expectations before opening\nvar kind, settings string; var schema int\ndb.QueryRow(\"SELECT kind, schema_version, cipher_settings FROM encrypted_index_meta\").Scan(&kind, &schema, &settings)","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"incompatible encrypted index\") {\n    // trigger authenticated reindex of the affected documents\n}","preventionTips":["Keep all machines in a sync group on the same kernel version","Do not change cipher parameters (page size, KDF iterations) on existing notebooks","Read release notes for schema bumps; rebuild indexes as instructed","Never hand-edit encrypted_index_meta to force a match"],"tags":["database","encryption","schema","compatibility"],"backgroundTag":"incompatible-source-type","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}