{"record":{"id":"a124cc6221e46941","repo":"siyuan-note/siyuan","slug":"conf-language-26-a124cc","errorCode":null,"errorMessage":"Conf.Language(26)","messagePattern":"Conf\\.Language\\(26\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history_diff.go","lineNumber":402,"sourceCode":"\t\t}, nil\n\t}\n\treturn &loadedDocVersion{\n\t\ttree:    tree,\n\t\ttitle:   tree.Root.IALAttr(\"title\"),\n\t\trootID:  tree.Root.ID,\n\t\traw:     data,\n\t\tlarge:   1024*1024 <= len(data),\n\t\tboxID:   boxID,\n\t\thistory: historyRoot,\n\t}, nil\n}\n\nfunc loadSnapshotDocVersion(fileID string) (ret *loadedDocVersion, err error) {\n\tif \"\" == fileID {\n\t\treturn nil, errors.New(\"snapshot file ID is required\")\n\t}\n\tif 1 > len(Conf.Repo.Key) {\n\t\treturn nil, errors.New(Conf.Language(26))\n\t}\n\trepo, err := newRepository()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfile, err := repo.GetFile(fileID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !strings.HasSuffix(strings.ToLower(file.Path), \".sy\") {\n\t\treturn nil, errors.New(\"snapshot version is not a document\")\n\t}\n\trepoPath := strings.TrimPrefix(file.Path, \"/\")\n\tpathParts := strings.SplitN(repoPath, \"/\", 2)\n\tdata, err := repo.OpenFile(file)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/history_diff.go#L384-L420","documentation":"Loading a snapshot document version requires the repository encryption key (Conf.Repo.Key) to be present, since snapshots are stored encrypted. If no repo key is configured (key length < 1), the kernel returns localized message key 26, which tells the user to set the repo key / passphrase first.","triggerScenarios":"Calling loadDocVersion for a snapshot version when no sync/repo passphrase has ever been generated or entered in this workspace.","commonSituations":"Fresh workspace without encryption key setup; accessing history before configuring cloud sync and its passphrase; Conf not yet initialized with Repo.Key.","solutions":["Generate or enter the repo encryption key in Settings - About (or via the repo key API), then retry","Check len(Conf.Repo.Key) before requesting snapshot versions","Ensure i18n key 26 exists in all language files if localizing"],"exampleFix":"// before\nloadDocVersion(fileID) // no repo key configured\n// after\n// set Conf.Repo.Key via the kernel repo-key API first, then:\nloadDocVersion(fileID)","handlingStrategy":"validation","validationCode":"if (!window.siyuan.config.repo.key) { showToast(i18n[26]); openRepoKeyDialog(); }","typeGuard":"const hasRepoKey = (conf: IConfig) => typeof conf.repo?.key === \"string\" && conf.repo.key.length > 0;","tryCatchPattern":"try { await api.loadDocVersion(fileID); } catch (e) { if (String(e) === i18n[26]) { await promptForRepoKey(); retry(); } }","preventionTips":["Set up the repo encryption key before using snapshot history or sync","Check repo key presence in the history UI before listing snapshot versions","Document the key requirement in onboarding/setup flows"],"tags":["encryption","snapshot","repo-key","config"],"backgroundTag":"missing-api-key","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"}