siyuan-note/siyuan · error

encrypted notebook cannot be saved as a normal notebook

Error message

encrypted notebook cannot be saved as a normal notebook

What it means

prepareBoxConfForSave downgrade guard: the incoming conf marks the notebook as not encrypted, but the notebook is currently registered as encrypted on disk. Saving would silently drop the encryption envelope, so the save is refused — the notebook must be properly decrypted/unlocked through the encrypted-notebook flow first.

Source

Thrown at kernel/model/box_conf_crypto.go:99

	if err := decryptBoxMetadata(boxID, boxConf, dek); err != nil {
		setEncryptedBoxState(boxID, EncryptedBoxStateError)
		return err
	}
	return nil
}

func prepareBoxConfForSave(boxID string, boxConf *conf.BoxConf) (*conf.BoxConf, error) {
	if boxConf == nil {
		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)

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Use the proper decrypt/remove-protection flow to convert the notebook to normal
  2. Do not hand-edit conf.json of an encrypted notebook
  3. If the state is stale, verify with GetEncryptedBoxState before retrying
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at kernel/model/box_conf_crypto.go:99 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/530f5dff252d4cdc. Report an issue: GitHub.