siyuan-note/siyuan · error

Conf.Language(123)

Error message

Conf.Language(123)

What it means

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.

Solutions

  1. Set a valid cloud sync directory via SetCloudSyncDir / the sync settings dialog (设置 - 同步 - 云端同步目录) before retrying.
  2. If sync is not actually intended, disable sync (Conf.Sync.Enabled = false) so the precondition is skipped.
  3. Verify conf.json's sync.cloudName value matches an existing cloud directory name.

Example fix

// before
model.SyncDataBeforeEnableEncryptedNotebook()
// after
if conf.Sync.Enabled && !cloud.IsValidCloudDirName(conf.Sync.CloudName) {
    model.SetCloudSyncDir("my-sync-dir")
}
model.SyncDataBeforeEnableEncryptedNotebook()
Defensive patterns

Strategy: validation

Validate before calling

// Go: check before enabling
if conf.Sync.Enabled && !cloud.IsValidCloudDirName(conf.Sync.CloudName) {
    // fix the cloud dir first
}

Try / catch

if err := model.SyncDataBeforeEnableEncryptedNotebook(); err != nil {
    // if the message matches Language(123), guide the user to pick a valid cloud sync dir
    return fmt.Errorf("enable blocked: %w", err)
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/8d92c49575798723. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/sync.go:233

	if 1 == code {
		// 启动同步成功后消费本地速记临时文件,避免移动端开启云同步时需手动触发同步才能刷新闪念速记
		consumeShorthands()
	}
	return
}

func SyncData(byHand bool) {
	syncData(false, byHand)
}

// SyncDataBeforeEnableEncryptedNotebook 在启用加密笔记本前执行一次完整同步。
// 未启用数据同步时直接返回;已启用数据同步时,任何同步失败都会阻止继续创建新的密钥体系。
func SyncDataBeforeEnableEncryptedNotebook() error {
	if !Conf.Sync.Enabled {
		return nil
	}
	if !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 8641553a1f)