siyuan-note/siyuan · error

Conf.Language(324)

Error message

Conf.Language(324)

What it means

Conf.Language(324) is the localized refusal message shown when importing a notebook-crypto backup would overwrite an existing, complete, enabled encryption configuration. ImportNotebookCryptoBackup intentionally rejects the import to avoid replacing the current salt/verifier and orphaning existing WrappedDEKs (data that could no longer be decrypted).

Solutions

  1. If the existing configuration is the one you want, do not import — the machine is already set up; use the master password to unlock
  2. If you truly need to switch to the imported configuration, first disable/reset the current notebook-crypto configuration (following the documented recovery procedure and keeping recovery material), then import
  3. Verify which workspace/machine you are on — the backup likely belongs to a different device; import it there instead

Example fix

// caller-side precheck
const conf = window.siyuan.config.localNotebookCrypto;
if (conf?.enabled) { showMessage("Encryption already configured on this device; import refused"); return; }
await fetchPost("/api/notebook/importNotebookCryptoBackup", {data, password});
Defensive patterns

Strategy: validation

Validate before calling

const cfg = window.siyuan?.config?.localNotebookCrypto;
if (cfg?.enabled) {
  showMessage("This device already has encryption configured; import refused");
  return;
}

Type guard

const cryptoAlreadyConfigured = (cfg) => !!cfg && cfg.enabled === true && !!cfg.masterSalt;

Try / catch

try {
  const res = await fetchSyncPost("/api/notebook/importNotebookCryptoBackup", {data, password});
  if (res.code !== 0) showMessage(res.msg);
} catch (e) {
  showMessage("Import refused: encryption already configured on this device");
}

Prevention

When it happens

Trigger: Calling model.ImportNotebookCryptoBackup(data, password) (kernel/model/crypto.go:326) when Conf.NotebookCrypto.Enabled is true and the current configuration is complete (notebookCryptoConfigurationComplete) — i.e. the machine already has working encryption configured. Also reached from TestPasswordChangePreservesDeletedHistoryRecovery.

Common situations: User drags a key-backup file into a machine that already has encryption enabled and configured; an automation re-imports the same backup after a successful setup; testing scripts import twice without resetting config.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/d7373ee56986d80a. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/crypto.go:326

}

// ImportNotebookCryptoBackup 接收用户导入的密钥备份文件内容(JSON 字节),
// 校验为合法 NotebookCrypto 后写回 <DataDir>/.siyuan/data-crypto-backup.json 并装回本机 Conf。
// 用于新设备/重装后不依赖同步、手动恢复加密配置(详见设计文档 §4.1)。
// 安全:备份文件不含主密码(salt 不保密、verifier 是密文),导入只恢复配置,解锁仍需主密码。
// 防呆:本机已有完整且已启用的加密配置时拒绝导入,避免覆盖现有 salt/verifier 孤立现有 WrappedDEK。
// ImportNotebookCryptoBackup 接收用户导入的密钥备份文件内容(JSON 字节)+ 主密码,
// 校验主密码能解开备份里的 verifier 后才写回配置。防止 crafted 备份设置弱 KDFParams 等攻击。
// RecoveryRequired 状态允许导入,但候选 KEK 必须能解开所有现存笔记本和已删除笔记本历史。
func ImportNotebookCryptoBackup(data []byte, password string) error {
	notebookCryptoMu.Lock()
	defer notebookCryptoMu.Unlock()

	Conf.m.RLock()
	current := *Conf.NotebookCrypto
	Conf.m.RUnlock()
	if current.Enabled && notebookCryptoConfigurationComplete(&current) {
		return errors.New(Conf.Language(324))
	}

	nc := &conf.NotebookCrypto{}
	if err := json.Unmarshal(data, nc); err != nil {
		return errors.New(Conf.Language(317))
	}
	if !notebookCryptoConfigurationComplete(nc) {
		return errors.New(Conf.Language(317))
	}

	// 用导入的 salt + 用户输入的主密码派生 KEK,校验能否解开备份里的 verifier
	params, validErr := util.ValidateArgon2Params(nc.KDFParams)
	if validErr != nil {
		return errors.New(Conf.Language(317))
	}
	kek := util.DeriveKey(password, nc.MasterSalt, params)
	defer zeroAndClear(kek)
	if nc.Checksum != computeBackupChecksum(nc) {

View on GitHub (pinned to 9f775e8a12)