siyuan-note/siyuan · error
missing encrypted index setting
Error message
missing encrypted index setting %s
What it means
CheckEncryptedIndexCompatibility requires every SQLCipher cipher PRAGMA (cipher_version, cipher_page_size, kdf_iter, cipher_hmac_algorithm, cipher_kdf_algorithm, cipher_use_hmac) to return a non-empty value. An empty value means cipher settings are not visible on this connection, so compatibility cannot be authenticated and the index is rejected.
Solutions
- Identify the empty setting from the error message and compare with the SQLCipher version in use
- Delete and let the caller rebuild the index from authenticated source documents (the sanctioned recovery path)
- Restore the index from sync snapshot or backup if rebuilding is undesirable
- Ensure the same SQLCipher build/version is used across kernel upgrades
Defensive patterns
Strategy: fallback
Validate before calling
for _, p := range []string{"cipher_version","cipher_page_size","kdf_iter"} {
var v string
db.QueryRow("PRAGMA " + p).Scan(&v)
if v == "" { /* rebuild index from authenticated source */ }
} Prevention
- Treat an empty cipher PRAGMA as a signal to rebuild, never to bypass
- Keep kernel and SQLCipher versions consistent across machines in a sync group
- Let the kernel create encrypted indexes itself; do not copy plain index files in
When it happens
Trigger: Opening an encrypted index whose PRAGMA query succeeds but returns an empty string for one of the six settings — e.g. the DB was opened without the SQLCipher key so cipher PRAGMAs are unset, or an index created by a driver lacking one of the settings.
Common situations: Index file created before encryption finished initializing (interrupted first open); driver version change making a PRAGMA unimplemented; a plain (unencrypted) index opened through the encrypted-open path.
Understand the failure class
Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.
Related errors
- read encrypted index setting
- Conf.Language(381)
- encrypted blocktree db not opened for box
- encrypted box db not opened for box
- encrypted box db not opened for box
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/eaf439255d3ac285.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/util/encrypted_index.go:24
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
)
// CheckEncryptedIndexCompatibility 将索引版本保存在受 SQLCipher 认证的表中,拒绝复用缺少版本或参数不匹配的旧索引。
// schema 由各索引维护,修改表结构时递增;索引重建由已认证源文档的调用方负责。
func CheckEncryptedIndexCompatibility(db *sql.DB, kind string, schema int) error {
settings := map[string]string{}
for _, name := range []string{"cipher_version", "cipher_page_size", "kdf_iter", "cipher_hmac_algorithm", "cipher_kdf_algorithm", "cipher_use_hmac"} {
var value string
if err := db.QueryRow("PRAGMA " + name).Scan(&value); err != nil {
return fmt.Errorf("read encrypted index setting %s: %w", name, err)
}
if value == "" {
return fmt.Errorf("missing encrypted index setting %s", name)
}
settings[name] = value
}
encoded, err := json.Marshal(settings)
if err != nil {
return err
}
var metadataTables int
if err = db.QueryRow("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = 'encrypted_index_meta'").Scan(&metadataTables); err != nil {
return err
}
if metadataTables == 0 {
var tables int
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")View on GitHub (pinned to 9f775e8a12)