{"record":{"id":"8d92c49575798723","repo":"siyuan-note/siyuan","slug":"conf-language-123","errorCode":null,"errorMessage":"Conf.Language(123)","messagePattern":"Conf\\.Language\\(123\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/sync.go","lineNumber":233,"sourceCode":"\tif 1 == code {\n\t\t// 启动同步成功后消费本地速记临时文件，避免移动端开启云同步时需手动触发同步才能刷新闪念速记\n\t\tconsumeShorthands()\n\t}\n\treturn\n}\n\nfunc SyncData(byHand bool) {\n\tsyncData(false, byHand)\n}\n\n// SyncDataBeforeEnableEncryptedNotebook 在启用加密笔记本前执行一次完整同步。\n// 未启用数据同步时直接返回；已启用数据同步时，任何同步失败都会阻止继续创建新的密钥体系。\nfunc SyncDataBeforeEnableEncryptedNotebook() error {\n\tif !Conf.Sync.Enabled {\n\t\treturn nil\n\t}\n\tif !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {\n\t\treturn errors.New(Conf.Language(123))\n\t}\n\tif !checkSync(false, false, true) {\n\t\treturn errors.New(Conf.Language(53))\n\t}\n\n\t// 不复用请求合并状态，确保调用返回前确实完成了一次由当前启用操作发起的完整同步。\n\tlockSync()\n\tdefer unlockSync()\n\tif err := syncDataLocked(false, true); err != nil {\n\t\tif Conf.Sync.Stat != \"\" {\n\t\t\treturn errors.New(Conf.Sync.Stat)\n\t\t}\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc lockSync() {","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/sync.go#L215-L251","documentation":"SyncDataBeforeEnableEncryptedNotebook runs a full sync before the user enables the encrypted-notebook key system, because switching key systems requires the cloud copy to be consistent. If sync is enabled but Conf.Sync.CloudName is not a valid cloud directory name (checked by cloud.IsValidCloudDirName), it returns localized message 123 and blocks enabling. This prevents creating a new key envelope on top of a misconfigured or missing cloud sync target.","triggerScenarios":"Calling /api/sync/enableEncryptedNotebookWithSync (EnableEncryptedNotebookWithSync) while Conf.Sync.Enabled is true but Conf.Sync.CloudName is empty, whitespace-like, or contains characters the cloud backend rejects (cloud.IsValidCloudDirName fails).","commonSituations":"User enabled sync previously but the cloud sync directory was never created or was cleared; configuration migrated from another workspace leaving CloudName blank; manual edits to conf.json corrupting the sync settings.","solutions":["Set a valid cloud sync directory via SetCloudSyncDir / the sync settings dialog (设置 - 同步 - 云端同步目录) before retrying.","If sync is not actually intended, disable sync (Conf.Sync.Enabled = false) so the precondition is skipped.","Verify conf.json's sync.cloudName value matches an existing cloud directory name."],"exampleFix":"// before\nmodel.SyncDataBeforeEnableEncryptedNotebook()\n// after\nif conf.Sync.Enabled && !cloud.IsValidCloudDirName(conf.Sync.CloudName) {\n    model.SetCloudSyncDir(\"my-sync-dir\")\n}\nmodel.SyncDataBeforeEnableEncryptedNotebook()","handlingStrategy":"validation","validationCode":"// Go: check before enabling\nif conf.Sync.Enabled && !cloud.IsValidCloudDirName(conf.Sync.CloudName) {\n    // fix the cloud dir first\n}","typeGuard":null,"tryCatchPattern":"if err := model.SyncDataBeforeEnableEncryptedNotebook(); err != nil {\n    // if the message matches Language(123), guide the user to pick a valid cloud sync dir\n    return fmt.Errorf(\"enable blocked: %w\", err)\n}","preventionTips":["Always set a valid cloud sync directory via the sync settings before enabling encryption","Do not hand-edit conf.json sync fields","Verify sync works once (manual sync) before enabling the encrypted notebook"],"tags":["go","sync","cloud","config-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}