{"record":{"id":"d5136649ac2012c4","repo":"siyuan-note/siyuan","slug":"conf-language-314","errorCode":null,"errorMessage":"Conf.Language(314)","messagePattern":"Conf\\.Language\\(314\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history.go","lineNumber":195,"sourceCode":"\trelPath := strings.TrimPrefix(filepath.ToSlash(historyPath), filepath.ToSlash(util.HistoryDir))\n\trelPath = strings.TrimPrefix(relPath, \"/\")\n\tpathParts := strings.SplitN(relPath, \"/\", 3)\n\tciphertext := util.IsCiphertext(data)\n\tif ciphertext {\n\t\tif len(pathParts) < 3 || !ast.IsNodeIDPattern(pathParts[1]) {\n\t\t\terr = errors.New(\"encrypted document history is missing notebook context\")\n\t\t\treturn\n\t\t}\n\t\thistBoxID := pathParts[1]\n\t\tif !IsEncryptedBox(histBoxID) {\n\t\t\terr = fmt.Errorf(\"encrypted document history has no matching notebook [%s]\", histBoxID)\n\t\t\treturn\n\t\t}\n\t\tHoldBoxReadLock(histBoxID)\n\t\tdefer ReleaseBoxReadLock(histBoxID)\n\t\tdek, dekErr := GetDEKIfUnlocked(histBoxID)\n\t\tif dekErr != nil {\n\t\t\terr = errors.New(Conf.Language(314))\n\t\t\treturn\n\t\t}\n\t\tdata, err = DecryptFile(histBoxID, pathParts[2], dek, data)\n\t\tif err != nil {\n\t\t\tlogging.LogErrorf(\"decrypt history [%s] failed: %s\", historyPath, err)\n\t\t\treturn\n\t\t}\n\t} else if len(pathParts) >= 2 && IsEncryptedBox(pathParts[1]) {\n\t\terr = fmt.Errorf(\"encrypted notebook document history is plaintext [%s]\", pathParts[1])\n\t\treturn\n\t}\n\tisLargeDoc = 1024*1024*1 <= len(data)\n\n\tluteEngine := NewLute()\n\tif err = treenode.CheckSpecJSON(data); nil != err {\n\t\treturn\n\t}\n\thistoryTree, err := dataparser.ParseJSONWithoutFix(data, luteEngine.ParseOptions)","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/history.go#L177-L213","documentation":"When reading encrypted document history the kernel needs the notebook's DEK. GetDEKIfUnlocked returns an error when the DEK is unavailable, most commonly because the notebook is locked (not unlocked with its passphrase). The kernel then surfaces Conf.Language(314): 'Please unlock the encrypted notebook first'.","triggerScenarios":"Opening a history snapshot of an encrypted notebook that is currently locked; accessing history right after app boot before the user unlocked the notebook; DEK cache cleared after re-key operations.","commonSituations":"Browsing history panel while the encrypted notebook is locked; scripted history export running before unlock; a resumed session where the notebook was re-locked by idle timeout.","solutions":["Unlock the encrypted notebook (open it / enter passphrase) and retry reading the history","Ensure the notebook is not closed; open it before requesting history content","If unlock fails, verify the access key / passphrase for the notebook"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const box = (await fetchPost('/api/notebook/lsNotebooks', {})).notebooks.find(n => n.id === boxID);\nif (box && box.closed) await fetchPost('/api/notebook/openNotebook', {notebook: boxID}); // triggers unlock flow","typeGuard":null,"tryCatchPattern":"try {\n  return await fetchPost('/api/history/getDocHistoryContent', {historyPath});\n} catch (e) {\n  if (String(e.msg).includes('unlock the encrypted notebook')) {\n    await promptUnlock(boxID); // user enters passphrase\n    return fetchPost('/api/history/getDocHistoryContent', {historyPath}); // retry once\n  } else throw e;\n}","preventionTips":["Unlock encrypted notebooks before scripted history reads","Queue history operations until after the unlock prompt resolves","Surface the 'please unlock' message to the user rather than failing silently"],"tags":["history","encrypted-notebook","locked"],"backgroundTag":"authentication-required","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}