siyuan-note/siyuan · error
The synchronization function can only be activated after…
Error message
The synchronization function can only be activated after adding/selecting the cloud synchronization directory
What it means
SyncDataBeforeEnableEncryptedNotebook performs a forced sync before a new encryption key system is created. If sync is enabled but no valid cloud sync directory is configured (and the provider is not S3), it returns the localized message for language key 123: sync can only be activated after adding/selecting the cloud sync directory. Without a target directory the mandatory pre-enable sync cannot run, and proceeding could fork encrypted data.
Solutions
- Open Settings - Sync and select/create a cloud sync directory before enabling the encrypted notebook
- Set Conf.Sync.CloudName to a valid directory name (validated by cloud.IsValidCloudDirName)
- Alternatively switch the provider to S3, which bypasses the cloud directory name requirement
Defensive patterns
Strategy: validation
Validate before calling
if (window.siyuan.config.sync.enabled &&
window.siyuan.config.sync.provider !== 3 /* S3 */ &&
!window.siyuan.config.sync.cloudName) {
alert("Select a cloud sync directory first");
return;
} Try / catch
if err := model.SyncDataBeforeEnableEncryptedNotebook(); err != nil {
// surface Conf.Language(123)-style message; prompt user to pick a directory
} Prevention
- Always configure the cloud sync directory before enabling encrypted notebooks
- Check Conf.Sync.CloudName is non-empty when provider is not S3
- Expose directory selection in the enable flow rather than calling the API directly
When it happens
Trigger: Calling EnableEncryptedNotebookWithSync (which invokes this) while Conf.Sync.Enabled is true but Conf.Sync.CloudName is empty or invalid and provider != S3.
Common situations: User enabled sync toggle but never picked a cloud directory; config file edited manually leaving CloudName blank; migrating config from another workspace where the directory name was lost.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Data synchronization has not been enabled
- Conf.Language(249)
- Conf.Sync.Stat
- AI configuration is unavailable
- Conf.Language(12)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/8e51d78c0cf1d6cc.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/sync.go:237
if 1 == code {
// 启动同步成功后消费本地速记临时文件,避免移动端开启云同步时需手动触发同步才能刷新闪念速记
consumeShorthands()
}
return
}
func SyncData(byHand bool) {
syncData(false, byHand)
}
// SyncDataBeforeEnableEncryptedNotebook 在启用加密笔记本前执行一次完整同步。
// 未启用数据同步时直接返回;已启用数据同步时,任何同步失败都会阻止继续创建新的密钥体系。
func SyncDataBeforeEnableEncryptedNotebook() error {
if !Conf.Sync.Enabled {
return nil
}
if conf.ProviderS3 != Conf.Sync.Provider && !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
return errors.New(Conf.Language(123))
}
if !checkSync(false, false, true) {
return errors.New(Conf.Language(53))
}
// 不复用请求合并状态,确保调用返回前确实完成了一次由当前启用操作发起的完整同步。
lockSync()
defer unlockSync()
if err := syncDataLocked(false, true); err != nil {
if Conf.Sync.Stat != "" {
return errors.New(Conf.Sync.Stat)
}
return err
}
return nil
}
func lockSync() {View on GitHub (pinned to 9f775e8a12)