siyuan-note/siyuan · error

encrypted notebook is in an error state

Error message

encrypted notebook is in an error state

What it means

prepareBoxConfForSave state guard: the notebook's runtime encrypted-box state is EncryptedBoxStateError (a prior decrypt/verify operation failed), so persisting a new encrypted conf is refused. Writing now could overwrite a suspect envelope and worsen recovery.

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 8641553a1f)

Solutions

  1. Resolve the underlying error state first (verify password/key, restore backup)
  2. Retry the save only after the box leaves the error state
  3. Preserve existing data; never regenerate keys to bypass the error
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at kernel/model/box_conf_crypto.go:108 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/e7d59de193c01857. Report an issue: GitHub.