siyuan-note/siyuan · error
encrypted notebook is in an error state
Error message
encrypted notebook is in an error state
What it means
The encrypted notebook's runtime state is marked EncryptedBoxStateError — an earlier decrypt/unlock step already failed — so prepareBoxConfForSave refuses to persist a new conf to avoid writing data derived from a broken encryption state. The save is aborted until the notebook's encryption state is fixed.
Solutions
- Re-unlock the notebook with the correct passphrase to clear the error state and repopulate the DEK cache
- Restore the notebook's .siyuan config/metadata from a known-good backup, then retry
- Restart the kernel and retry in case the error state came from a transient decryption failure
- If the notebook's encryption state is unrecoverable, use the documented recovery/migration path rather than forcing a save
Defensive patterns
Strategy: try-catch
Validate before calling
if GetEncryptedBoxState(boxID) == EncryptedBoxStateError {
// require unlock/recovery before any save
} Try / catch
_, err := prepareBoxConfForSave(boxID, boxConf)
if err != nil && GetEncryptedBoxState(boxID) == EncryptedBoxStateError {
// surface recovery UI: re-enter passphrase or restore backup
} Prevention
- Fix decryption failures promptly instead of saving through an error state
- Re-unlock notebooks after key-material changes
- Monitor box encryption state before batch conf writes
When it happens
Trigger: SaveConf on a notebook for which GetEncryptedBoxState(boxID)==EncryptedBoxStateError, typically set by revealBoxMetadataIfUnlocked or unlockBoxHeld after a decryption/AAD verification failure earlier in the session.
Common situations: User entered a wrong passphrase earlier leaving the box in error state; metadata ciphertext corrupted; key material mismatch after restoring data from a different workspace without its keys.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- cannot replay block swap across encrypted notebook…
- cannot swap blocks across encrypted notebook boundaries
- CLI does not support encrypted notebook
- Conf.Language(314)
- Conf.Language(314)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/e7d59de193c01857.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/box_conf_crypto.go:108
return nil, errors.New("notebook configuration is missing")
}
persisted := *boxConf
persisted.BoxCrypt = DeepCopyBoxEncryption(boxConf.BoxCrypt)
if persisted.Encrypted {
forgetRuntimeNormalBox(boxID)
}
if !persisted.Encrypted {
if IsEncryptedBox(boxID) {
return nil, errors.New("encrypted notebook cannot be saved as a normal notebook")
}
return &persisted, nil
}
if persisted.BoxCrypt == nil {
clearBoxMetadata(&persisted)
return &persisted, nil
}
if GetEncryptedBoxState(boxID) == EncryptedBoxStateError {
return nil, errors.New("encrypted notebook is in an error state")
}
if dek, ok := cachedDEKCopy(boxID); ok {
defer zeroAndClear(dek)
if err := reuseBoxMetadataIfUnchanged(boxID, &persisted, dek); err != nil {
return nil, err
}
} else if len(persisted.BoxCrypt.Metadata) == 0 {
existing, err := readRawBoxConf(boxID)
if err != nil {
return nil, err
}
if existing == nil || existing.BoxCrypt == nil || len(existing.BoxCrypt.Metadata) == 0 {
return nil, errors.New("encrypted notebook metadata is missing")
}
persisted.BoxCrypt.Metadata = append([]byte(nil), existing.BoxCrypt.Metadata...)
}
if err := validateBoxEncryption(persisted.BoxCrypt); err != nil {View on GitHub (pinned to 9f775e8a12)