{"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":229,"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":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/sync.go#L211-L247","documentation":"SyncDataBeforeEnableEncryptedNotebook (called from crypto.go:954) aborts with Conf.Language(123) = 'The synchronization function can only be activated after adding/selecting the cloud synchronization directory' when Conf.Sync.CloudName fails cloud.IsValidCloudDirName. Enabling an encrypted notebook requires a prior full sync, and that sync needs a valid cloud directory/bucket selected.","triggerScenarios":"The user turns on notebook encryption while data sync is enabled in Settings but no valid cloud sync directory is configured (CloudName empty, contains spaces/special chars, or exceeds 63 chars). The crypto-enable flow calls SyncDataBeforeEnableEncryptedNotebook, which short-circuits before any network call.","commonSituations":"Sync was enabled with a stale or cleared CloudName after a provider switch. The cloud directory was deleted out-of-band and the local config still references it. Fresh install where sync was toggled on but the directory was never created/selected.","solutions":["Open Settings - Cloud - Cloud sync directory and either create or select a valid directory first.","Ensure CloudName matches \\w[-\\w]*, no spaces/symbols, length <= 63 (cloud.IsValidCloudDirName rules).","After selecting the directory, retry enabling notebook encryption."],"exampleFix":"// before: Sync.Enabled=true, CloudName=\"\" -> error 123\n// after: pick a directory first\nif !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {\n    Conf.Sync.CloudName = \"main\" // or CreateCloudSyncDir then set\n    Conf.Save()\n}","handlingStrategy":"validation","validationCode":"// Go: gate the encryption-enable action\nif Conf.Sync.Enabled && !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {\n    return errors.New(\"select a cloud sync directory before enabling encryption\")\n}","typeGuard":"// Go\nfunc syncDirReady() bool {\n    return Conf.Sync.Enabled && cloud.IsValidCloudDirName(Conf.Sync.CloudName)\n}","tryCatchPattern":null,"preventionTips":["In the encryption-enable UI, pre-check that a cloud sync directory exists; disable Enable if not.","When changing sync provider, validate CloudName against the new provider's naming rules.","Document that encryption requires both sync enabled and a valid directory."],"tags":["sync","crypto","encryption","cloud","i18n","kernel","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}