siyuan-note/siyuan · error
invalid encrypted index compatibility metadata
Error message
invalid encrypted index compatibility metadata
What it means
The encrypted_index_meta table must contain exactly one row holding the index kind, schema version, and cipher settings. Zero rows (empty table) or multiple rows mean the compatibility metadata is corrupted or was written incorrectly, so the kernel cannot authenticate the index and refuses to open it.
Solutions
- Discard the index and let the kernel rebuild it from the authenticated source documents (delete the affected index DB and restart)
- Restore the database from sync or history backup
- Avoid opening the same workspace with multiple kernel processes concurrently
- Check disk/filesystem health if corruption recurs
Defensive patterns
Strategy: fallback
Validate before calling
var rows int
db.QueryRow("SELECT count(*) FROM encrypted_index_meta").Scan(&rows)
if rows != 1 { /* metadata corrupted: rebuild index from source */ } Prevention
- Avoid running multiple kernel instances against one workspace
- Protect the data directory from disk corruption (monitor disk health)
- Do not run ad-hoc SQL against index databases
When it happens
Trigger: Opening an encrypted index where SELECT count(*) FROM encrypted_index_meta returns anything other than 1 — duplicated metadata rows from a failed partial write, a manually truncated/cleared meta table, or corruption after a crash during meta-table creation.
Common situations: Interrupted index creation leaving an empty meta table; concurrent processes writing metadata twice; manual SQL manipulation of the index database; disk corruption.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- encrypted index has no compatibility metadata
- invalid encrypted notebook metadata envelope
- Conf.Language(381)
- database back relation value is invalid
- database history contains an invalid field
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/feb9b24224672b72.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/util/encrypted_index.go:56
if err = db.QueryRow("SELECT count(*) FROM sqlite_master WHERE type = 'table'").Scan(&tables); err != nil {
return err
}
if tables != 0 {
return errors.New("encrypted index has no compatibility metadata")
}
if _, err = db.Exec("CREATE TABLE encrypted_index_meta (kind TEXT NOT NULL, schema_version INTEGER NOT NULL, cipher_settings TEXT NOT NULL)"); err != nil {
return err
}
_, err = db.Exec("INSERT INTO encrypted_index_meta VALUES (?, ?, ?)", kind, schema, string(encoded))
return err
}
var storedKind, storedSettings string
var storedSchema, rows int
if err = db.QueryRow("SELECT count(*) FROM encrypted_index_meta").Scan(&rows); err != nil {
return err
}
if rows != 1 {
return errors.New("invalid encrypted index compatibility metadata")
}
if err = db.QueryRow("SELECT kind, schema_version, cipher_settings FROM encrypted_index_meta").Scan(&storedKind, &storedSchema, &storedSettings); err != nil {
return err
}
if storedKind != kind || storedSchema != schema || storedSettings != string(encoded) {
return errors.New("incompatible encrypted index")
}
return nil
}
View on GitHub (pinned to 9f775e8a12)