siyuan-note/siyuan · error
encrypted notebook metadata is missing
Error message
encrypted notebook metadata is missing
What it means
This error means the encrypted notebook's configuration has no encrypted metadata blob (BoxCrypt.Metadata) at all, so decryptBoxMetadata cannot attempt decryption. It is thrown as a guard before deriving the per-box subkey and calling DecryptWithAAD. It indicates the .siyuan box configuration for an encrypted notebook lost or never had its metadata ciphertext.
Solutions
- Check that the notebook's .siyuan box config file contains a non-empty BoxCrypt.Metadata field; if not, restore it from a backup or recreate the notebook configuration
- Verify the notebook is actually encrypted (Encrypted=true) and its metadata was produced by encryptBoxMetadata; if the notebook should be unencrypted, clear the stale Encrypted flag
- Re-open/unlock the notebook so the metadata is re-encrypted from current Icon/Sort/SortMode values via encryptBoxMetadata
- If the config is unrecoverable, back up the data directory and let SiYuan rebuild the notebook configuration
Example fix
// before: attempting decrypt with empty metadata
err := decryptBoxMetadata(boxID, boxConf, dek) // errors: metadata missing
// after: guard before calling
if boxConf != nil && boxConf.BoxCrypt != nil && len(boxConf.BoxCrypt.Metadata) > 0 {
err := decryptBoxMetadata(boxID, boxConf, dek)
} Defensive patterns
Strategy: validation
Validate before calling
if boxConf == nil || boxConf.BoxCrypt == nil || len(boxConf.BoxCrypt.Metadata) == 0 {
// restore from backup or re-enable encryption before decrypting
} Type guard
func hasEncryptedMetadata(bc *conf.BoxConf) bool {
return bc != nil && bc.BoxCrypt != nil && len(bc.BoxCrypt.Metadata) > 0
} Try / catch
if err := decryptBoxMetadata(boxID, boxConf, dek); err != nil {
// metadata missing or decryption failed: mark box in error state and prompt for recovery
setEncryptedBoxState(boxID, EncryptedBoxStateError)
} Prevention
- Never hand-edit the .siyuan box config of encrypted notebooks
- Back up the workspace before encryption-related operations
- Verify BoxCrypt.Metadata survived any backup/restore or sync
When it happens
Trigger: Called from revealBoxMetadataIfUnlocked, reuseBoxMetadataIfUnchanged, or unlockBoxHeld when boxConf is nil, boxConf.BoxCrypt is nil, or len(boxConf.BoxCrypt.Metadata)==0 for a notebook treated as encrypted (e.g. unlock flow reads a box conf whose Metadata field is empty).
Common situations: Hand-edited or partially written .siyuan box config files; a downgraded or buggy older version that did not encrypt metadata; restoring a notebook from a backup that dropped the metadata field; corruption after an interrupted save.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- encrypted notebook cannot be saved as a normal notebook
- cannot replay block swap across encrypted notebook…
- cannot swap blocks across encrypted notebook boundaries
- CLI does not support encrypted notebook
- Conf.Language(26)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/bdf3f675330a1545.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/box_conf_crypto.go:56
}
metadata := &encryptedBoxMetadata{
Icon: filterBoxIcon(boxConf.Icon),
Sort: boxConf.Sort,
SortMode: boxConf.SortMode,
}
plaintext, err := gulu.JSON.MarshalJSON(metadata)
if err != nil {
return err
}
key := util.DeriveSubKey(dek, "siyuan/box-metadata")
defer zeroAndClear(key)
boxConf.BoxCrypt.Metadata, err = util.EncryptWithAAD(key, plaintext, boxMetadataAAD(boxID))
return err
}
func decryptBoxMetadata(boxID string, boxConf *conf.BoxConf, dek []byte) error {
if boxConf == nil || boxConf.BoxCrypt == nil || len(boxConf.BoxCrypt.Metadata) == 0 {
return errors.New("encrypted notebook metadata is missing")
}
key := util.DeriveSubKey(dek, "siyuan/box-metadata")
defer zeroAndClear(key)
plaintext, err := util.DecryptWithAAD(key, boxConf.BoxCrypt.Metadata, boxMetadataAAD(boxID))
if err != nil {
return err
}
metadata := &encryptedBoxMetadata{}
if err = gulu.JSON.UnmarshalJSON(plaintext, metadata); err != nil {
return err
}
boxConf.Icon = filterBoxIcon(metadata.Icon)
boxConf.Sort = metadata.Sort
boxConf.SortMode = metadata.SortMode
return nil
}
func revealBoxMetadataIfUnlocked(boxID string, boxConf *conf.BoxConf) error {View on GitHub (pinned to 9f775e8a12)