{"record":{"id":"3dcdb5f31a6bde53","repo":"siyuan-note/siyuan","slug":"encrypted-notebooks-already-exist-but-the-master-k","errorCode":null,"errorMessage":"Encrypted notebooks already exist but the master key backup is missing. Restore the original conf.json or backup file to re-enable","messagePattern":"Encrypted notebooks already exist but the master key backup is missing\\. Restore the original conf\\.json or backup file to re-enable","errorType":"http","errorClass":null,"httpStatus":200,"severity":"error","filePath":"kernel/model/crypto.go","lineNumber":1009,"sourceCode":"\tif listErr != nil {\n\t\treturn fmt.Errorf(\"list encrypted notebooks failed: %w\", listErr)\n\t}\n\thasHistory, historyErr := scanEncryptedNotebookHistory()\n\tif historyErr != nil {\n\t\treturn fmt.Errorf(\"check encrypted notebook history failed: %w\", historyErr)\n\t}\n\thasBackup := filelock.IsExist(dataCryptoBackupPath())\n\tif hasEncrypted || hasHistory || hasBackup {\n\t\t// 现存笔记本、已删除笔记本历史或全局备份均表示已有密钥域，必须恢复并认证，不能生成新 MasterSalt。\n\t\tkek, restoreErr := tryRestoreNotebookCryptoFromBackupLocked(password)\n\t\tif kek != nil {\n\t\t\tzeroAndClear(kek)\n\t\t}\n\t\tif restoreErr != nil {\n\t\t\tif strings.Contains(restoreErr.Error(), Conf.Language(311)) {\n\t\t\t\treturn errors.New(Conf.Language(311))\n\t\t\t}\n\t\t\treturn errors.New(Conf.Language(315))\n\t\t}\n\t\tlogging.LogInfof(\"encrypted notebook re-enabled with authenticated recovery key material\")\n\t\treturn nil\n\t}\n\n\t// 不存在任何密钥依赖或备份时生成新的 MasterSalt。\n\tsalt, err := util.GenerateSalt()\n\tif err != nil {\n\t\treturn err\n\t}\n\tConf.m.RLock()\n\tkdfParams := Conf.NotebookCrypto.KDFParams\n\tConf.m.RUnlock()\n\tparams, validErr := util.ValidateArgon2Params(kdfParams)\n\tif validErr != nil {\n\t\treturn validErr\n\t}\n\tkek := util.DeriveKey(password, salt, params)","sourceCodeStart":991,"sourceCodeEnd":1027,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/crypto.go#L991-L1027","documentation":"Error \"Encrypted notebooks already exist but the master key backup is missing. Restore the original conf.json or backup file to re-enable\" thrown in siyuan-note/siyuan.","triggerScenarios":"Thrown at kernel/model/crypto.go:1009 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the original conf.json or the notebook crypto backup file into the workspace data directory, then retry enabling with the original master password.","The backup file lives in the data directory; recover it from a system backup, another synced device, or a snapshot.","If the key material is unrecoverable, delete the orphaned encrypted notebooks/history and enable encryption fresh (existing encrypted data will be lost)."],"exampleFix":"Restore the original conf.json or the notebook crypto backup file from before the feature was disabled, then re-enable; without the backup the existing encrypted notebooks cannot be unlocked.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}