{"record":{"id":"bbdb62c8fcbb3703","repo":"siyuan-note/siyuan","slug":"26-conf-language","errorCode":"26","errorMessage":"Conf.Language(26)","messagePattern":"Conf\\.Language\\(26\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/asset_download.go","lineNumber":374,"sourceCode":"\t\treturn data, err\n\t}\n\tif err = checkAssetDownloadAccess(); err != nil {\n\t\treturn nil, err\n\t}\n\thandleCloudError := cloudRepoErrorHandler()\n\tif err = repo.EnsureFileChunks(file, newSyncContext()); err != nil {\n\t\thandleCloudError(err)\n\t\treturn nil, fmt.Errorf(\"%s: %w\", Conf.Language(376), err)\n\t}\n\treturn repo.OpenFile(file)\n}\n\n// readRepoFileWithAssets 将仓库实例的创建和历史分块补齐纳入来源读锁。\nfunc readRepoFileWithAssets(fileID string) ([]byte, *entity.File, error) {\n\tassetDownloadSourceMu.RLock()\n\tdefer assetDownloadSourceMu.RUnlock()\n\tif Conf.Repo == nil || len(Conf.Repo.Key) == 0 {\n\t\treturn nil, nil, errors.New(Conf.Language(26))\n\t}\n\trepo, err := newRepositoryWithAssetSourceLocked()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tfile, err := repo.GetFile(fileID)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif boxID := encryptedBoxIDFromRepoPath(file.Path); boxID != \"\" && !IsBoxUnlocked(boxID) {\n\t\treturn nil, nil, errors.New(Conf.Language(314))\n\t}\n\tdata, err := openRepoFileWithAssets(repo, file)\n\treturn data, file, err\n}\n\nfunc ensureRepoSnapshotComplete(repo *dejavu.Repo, indexID string) error {\n\tindex, err := repo.GetIndex(indexID)","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/asset_download.go#L356-L392","documentation":"readRepoFileWithAssets refuses to operate when no data repo key is configured (Conf.Repo == nil or Conf.Repo.Key is empty). Error i18n code 26 instructs the user to initialize the data repo key in Settings - Account & Sync - Local Data Repo - Data repo key. The repo key is required to create the repository instance and decrypt snapshot data, so reads are impossible without it.","triggerScenarios":"Any caller of readRepoFileWithAssets (GetRepoFile, RollbackRepoSnapshotFile, OpenRepoSnapshotFile, ExportRepoFile, tests) executed on a workspace where the local data repo key was never initialized — e.g. sync never set up, or Conf.Repo wiped by config reset/migration.","commonSituations":"Fresh workspace or restored data directory without conf.json repo section; user cleared the repo key; automated scripts calling repo-file APIs on an uninitialized workspace.","solutions":["Initialize the data repo key via Settings - Account & Sync - Local Data Repo - Data repo key (set a passphrase to generate the key)","If the workspace previously had a key, restore the original conf.json — a new key cannot decrypt existing snapshots","Check that Conf.Repo persisted correctly after restart; investigate config write failures if it was set but is gone after boot"],"exampleFix":"// before: calling the API unconditionally\ndata, err := model.GetRepoFile(fileID)\n// after: guard on repo key presence\nif model.Conf.Repo == nil || len(model.Conf.Repo.Key) == 0 {\n    return errors.New(model.Conf.Language(26))\n}\ndata, err := model.GetRepoFile(fileID)","handlingStrategy":"validation","validationCode":"if model.Conf.Repo == nil || len(model.Conf.Repo.Key) == 0 {\n    return errors.New(model.Conf.Language(26))\n}","typeGuard":null,"tryCatchPattern":"data, err := model.GetRepoFile(fileID)\nif err != nil && strings.Contains(err.Error(), model.Conf.Language(26)) {\n    return errRepoKeyUninitialized\n}","preventionTips":["Initialize the data repo key immediately after creating a workspace","Back up conf.json so a restored workspace retains Conf.Repo.Key","Never reset config without preserving the repo key — existing snapshots become unreadable with a new key","In automation, assert repo key presence in a startup check"],"tags":["repo-key","configuration","encryption","initialization","i18n"],"backgroundTag":"missing-credentials","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}