siyuan-note/siyuan · error
formatRepoErrorMsg(err)
Error message
formatRepoErrorMsg(err)
What it means
If repo.CreateCloudRepo(name) returns an error, CreateCloudSyncDir wraps it via formatRepoErrorMsg and returns that. formatRepoErrorMsg maps well-known cloud/dejavu errors to localized messages (auth failed, object not found, cloud locked, repo fatal, time incorrect, deprecated version, check failed, service unavailable) and HTML-escapes the rest.
Source
Thrown at kernel/model/sync.go:676
break
default:
err = errors.New(Conf.Language(131))
return
}
name = util.RemoveInvalid(name)
if !cloud.IsValidCloudDirName(name) {
return errors.New(Conf.Language(37))
}
repo, err := newRepository()
if err != nil {
return
}
err = repo.CreateCloudRepo(name)
if err != nil {
err = errors.New(formatRepoErrorMsg(err))
return
}
return
}
func RemoveCloudSyncDir(name string) (err error) {
switch Conf.Sync.Provider {
case conf.ProviderSiYuan, conf.ProviderLocal:
break
default:
err = errors.New(Conf.Language(131))
return
}
msgId := util.PushMsg(Conf.Language(116), 15000)
repo, err := newRepository()
if err != nil {View on GitHub (pinned to 251596fc0d)
Solutions
- Re-login to SiYuan cloud (or fix S3/WebDAV credentials) and retry.
- Pick a unique directory name; list existing dirs first via /api/sync/listCloudSyncDir.
- If Stat/msg indicates 'cloud locked' or 'service unavailable', wait and retry.
- Correct system clock if the error mentions incorrect time.
Example fix
// runtime/network error; no code change
// before: createCloudSyncDir('work') -> auth failed (mapped to Conf.Language(31))
// after: re-login, then retry createCloudSyncDir('work') Defensive patterns
Strategy: try-catch
Validate before calling
// Cannot pre-validate server-side rejection, but can preflight existence: // GET /api/sync/listCloudSyncDir and ensure name is not already present.
Try / catch
// Go caller
if err := model.CreateCloudSyncDir(name); err != nil {
logging.LogErrorf("create cloud sync dir failed: %s", err)
return err // message is already localized via formatRepoErrorMsg
} Prevention
- List existing directories before creating to avoid name collisions.
- Ensure fresh cloud credentials before the create call.
- Read formatRepoErrorMsg output carefully; it carries the mapped root cause.
When it happens
Trigger: POST /api/sync/createCloudSyncDir reaches the network and the underlying provider rejects it: SiYuan cloud auth token expired, bucket already exists, name collision, cloud service unavailable, rate limited, or dejavu lock contention.
Common situations: SiYuan account not logged in / subscription expired. Trying to create a directory name that already exists on the cloud. Cloud under maintenance. Clock skew between client and server.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/c6ea9a595a5d2424.
Report an issue: GitHub.