{"record":{"id":"0b554239370af0bc","repo":"siyuan-note/siyuan","slug":"encrypted-notebook-feature-is-not-enabled","errorCode":null,"errorMessage":"Encrypted notebook feature is not enabled","messagePattern":"Encrypted notebook feature is not enabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/crypto.go","lineNumber":2543,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\treturn filelock.Copy(srcPath, destPath)\n}\n\n// CreateEncryptedBox 创建一个新的加密笔记本。可多次调用创建多个。\n// 前置：加密功能已启用。创建时需要主密码（临时派生 KEK 用于 wrap DEK，用完即弃）。\n// 创建后直接用生成的 DEK 打开加密 db 并缓存（已解锁状态），调用方随后调 openNotebook 即可挂载。\nfunc CreateEncryptedBox(name, password string) (id string, err error) {\n\tnotebookCryptoMu.Lock()\n\tdefer notebookCryptoMu.Unlock()\n\n\tConf.m.RLock()\n\tnotebookCrypto := *Conf.NotebookCrypto\n\tConf.m.RUnlock()\n\tif !notebookCrypto.Enabled || !notebookCryptoConfigurationComplete(&notebookCrypto) {\n\t\treturn \"\", errors.New(Conf.Language(310))\n\t}\n\n\tkek, err := deriveKEK(password)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer zeroAndClear(kek)\n\n\tid, err = createBox(name, false)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tsetEncryptedBoxState(id, EncryptedBoxStateUnlocking)\n\n\t// 若后续步骤失败，清理已创建的 box 目录和加密 db 文件，避免半创建状态\n\tcreatedBoxID := id\n\tdefer func() {\n\t\tif err != nil {","sourceCodeStart":2525,"sourceCodeEnd":2561,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/crypto.go#L2525-L2561","documentation":"Returned by CreateEncryptedBox when Conf.NotebookCrypto.Enabled is false or notebookCryptoConfigurationComplete returns false. You cannot create an encrypted notebook until the global encryption feature is enabled and fully configured (master password set, KDF parameters chosen). The message comes from Conf.Language(310): 'Encrypted notebook feature is not enabled'.","triggerScenarios":"CreateEncryptedBox is called via the API/UI before the user has enabled notebook encryption in settings. Also fires if the configuration is partially set (e.g., enabled flag is true but required KDF fields are missing).","commonSituations":"User clicks 'create encrypted notebook' without first going through the encryption-setup flow. Config file was manually edited, leaving Enabled=true but missing KDF parameters. Fresh install where setup wizard wasn't completed.","solutions":["Guide the user through enabling encryption first: set a master password and KDF parameters via the encryption settings UI/API.","Check notebookCryptoConfigurationComplete output to identify which specific config field is missing.","Ensure Conf.NotebookCrypto is loaded from disk (Conf is not nil and properly initialized) before calling CreateEncryptedBox."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check encryption feature state before creating an encrypted box\nConf.m.RLock()\nnc := *Conf.NotebookCrypto\nConf.m.RUnlock()\nif !nc.Enabled || !notebookCryptoConfigurationComplete(&nc) {\n    return errors.New(\"enable encryption in settings first\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guide users through the encryption setup wizard before exposing 'create encrypted notebook'.","Validate notebookCryptoConfigurationComplete in the UI to disable the create button when config is incomplete.","Ensure Conf is fully loaded before allowing notebook creation."],"tags":["encryption","notebook-creation","configuration","crypto"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}