siyuan-note/siyuan · error

Cannot disable encrypted notebooks: deleted-notebook history

Error message

Cannot disable encrypted notebooks: deleted-notebook history still depends on the current key backup. Clear that history first

What it means

Error "Cannot disable encrypted notebooks: deleted-notebook history still depends on the current key backup. Clear that history first" thrown in siyuan-note/siyuan.

Source

Thrown at kernel/model/crypto.go:1087

	notebookCryptoMu.Lock()
	defer notebookCryptoMu.Unlock()

	// 检查是否还有加密笔记本(含 conf 损坏但存在备份的)
	ids, listErr := listAllEncryptedBoxIDs()
	if listErr != nil {
		return fmt.Errorf("list encrypted notebooks failed: %w", listErr)
	}
	if len(ids) > 0 {
		return errors.New("cannot disable encrypted notebook feature while encrypted notebooks exist, remove them first")
	}
	// 检查历史目录中是否存在已删除加密笔记本的历史快照:其恢复仍依赖当前 MasterSalt/KEKVerifier,
	// 删除备份前必须先清除这些历史(详见设计 §19)
	hasHistory, historyErr := scanEncryptedNotebookHistory()
	if historyErr != nil {
		return fmt.Errorf("check encrypted notebook history failed: %w", historyErr)
	}
	if hasHistory {
		return errors.New(Conf.Language(323))
	}

	Conf.m.Lock()
	Conf.NotebookCrypto.Enabled = false
	Conf.NotebookCrypto.MasterSalt = nil
	Conf.NotebookCrypto.KEKVerifier = nil
	Conf.NotebookCrypto.VerifierNonce = nil
	Conf.m.Unlock()

	Conf.Save()
	removeNotebookCryptoBackup() // 禁用时清理备份,避免残留旧密钥材料
	IncSync()
	return nil
}

// restoreNotebookCryptoConfigFromBackup 把备份里的 NotebookCrypto 配置装回本机 conf.json(不需主密码)。
// 用于数据同步/导入 Data.zip 后:备份文件随 DataDir 到达新设备,但本机 conf.json 的 NotebookCrypto 还是空的。
// 此时把 salt/verifier/KDFParams 装回并置 Enabled=true,让 UI 显示"已启用",笔记本显示为锁定(解锁仍需主密码)。

View on GitHub (pinned to afa823b6b4)

Solutions

  1. Clear the history entries of deleted encrypted notebooks first (History - clear the affected entries), then disable the encrypted notebook feature.
  2. Disabling now would permanently lock those history snapshots because they still depend on the current key backup.

Example fix

Clear the deleted-notebook history (History - clear) for encrypted notebooks so it no longer depends on the current key backup, then disable the feature.

When it happens

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

Common situations: See trigger scenarios.


AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18). Data as JSON: /api/errors/1015b55e45f482c9. Report an issue: GitHub.