siyuan-note/siyuan · error
unknown cloud provider
Error message
unknown cloud provider [%d]
What it means
When building the cloud repository client, the kernel switches on Conf.Sync.Provider to instantiate the matching backend (S3, WebDAV, local). If the configured provider value matches no known conf.Provider* constant, newSyncRepository returns fmt.Errorf("unknown cloud provider [%d]"). This is an internal/config sanity guard — the UI only offers valid providers, so the value was set outside normal channels.
Solutions
- Open Settings - Account & Sync and reselect a valid cloud provider (S3/WebDAV/Local) to rewrite the enum
- Inspect conf.json and set "provider" under sync to a supported value (S3=2, WebDAV=3, Local=4 per conf package constants)
- Use the setConf API with a valid provider value instead of editing files while the kernel runs
- If caused by a version downgrade, reconfigure sync after restoring the newer version
Example fix
// before (hand-edited conf.json)
"sync": { "provider": 9 }
// after
"sync": { "provider": 3, "webdav": { "endpoint": "https://dav.example.com", ... } } Defensive patterns
Strategy: validation
Validate before calling
const VALID = new Set([2, 3, 4]); // S3, WebDAV, Local per conf package
const conf = (await (await fetch('/api/system/getConf', {method:'POST'})).json()).data;
if (!VALID.has(conf.sync?.provider)) throw new Error('sync.provider is not a supported cloud provider: ' + conf.sync?.provider); Type guard
function isValidProvider(p) { return p === 2 || p === 3 || p === 4; } // S3 | WebDAV | Local Try / catch
try {
await startSync();
} catch (e) {
const m = /unknown cloud provider \[(\d+)\]/.exec(e.message);
if (m) { await resetProviderToKnownGood(Number(m[1])); }
else throw e;
} Prevention
- Never hand-edit sync.provider in conf.json while the kernel is running
- Change providers only through Settings or /api/system/setConf with documented values
- Back up conf.json before config experiments
- Validate provider enum after restoring configs from backups or other versions
When it happens
Trigger: Conf.Sync.Provider holds an integer not matching any supported provider constant when a sync/repo operation constructs the cloud client (e.g. performSync, indexRepo, cloud snapshot ops).
Common situations: conf.json hand-edited or restored from another tool with an out-of-range provider number; plugin/script writing Sync.Provider directly; config from a newer/older version with different provider enum values; corrupted configuration.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid provider [ ]
- Conf.Language(249)
- Data synchronization has not been enabled
- full-manual mode requires 'push' or 'pull' subcommand
- The synchronization function can only be activated after…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/ed2ca83b20c85685.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/repository.go:3014
cloudRepo = cloud.NewSiYuan(&cloud.BaseCloud{Conf: cloudConf})
case conf.ProviderS3:
// 显式注入 SiYuan UA,覆盖 aws SDK 默认 UA(含架构、Go 版本、SDK 版本等冗余信息),便于 S3 服务端按 SiYuan/ 前缀识别加白名单
s3HTTPClient := httpclient.NewUserAgentClient(httpclient.NewTransport(cloudConf.S3.SkipTlsVerify))
s3HTTPClient.Timeout = time.Duration(cloudConf.S3.Timeout) * time.Second
cloudRepo = cloud.NewS3(&cloud.BaseCloud{Conf: cloudConf}, s3HTTPClient)
case conf.ProviderWebDAV:
webdavClient := gowebdav.NewClient(cloudConf.WebDAV.Endpoint, cloudConf.WebDAV.Username, cloudConf.WebDAV.Password)
a := cloudConf.WebDAV.Username + ":" + cloudConf.WebDAV.Password
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(a))
webdavClient.SetHeader("Authorization", auth)
webdavClient.SetHeader("User-Agent", util.UserAgent)
webdavClient.SetTimeout(time.Duration(cloudConf.WebDAV.Timeout) * time.Second)
webdavClient.SetTransport(httpclient.NewTransport(cloudConf.WebDAV.SkipTlsVerify))
cloudRepo = cloud.NewWebDAV(&cloud.BaseCloud{Conf: cloudConf}, webdavClient)
case conf.ProviderLocal:
cloudRepo = cloud.NewLocal(&cloud.BaseCloud{Conf: cloudConf})
default:
err = fmt.Errorf("unknown cloud provider [%d]", Conf.Sync.Provider)
return
}
ignoreLines, err := getSyncIgnoreLines()
if err != nil {
return nil, err
}
dataDir := util.DataDir
ret, err = dejavu.NewRepoWithOptions(dejavu.Options{
DataPath: util.DataDir, RepoPath: util.RepoDir, HistoryPath: util.HistoryDir, TempPath: util.TempDir,
DeviceID: Conf.System.ID, DeviceName: Conf.System.Name, DeviceOS: Conf.System.OS,
AESKey: Conf.Repo.Key, IgnoreLines: ignoreLines, Cloud: cloudRepo,
IgnoreRulePath: syncIgnoreRulePath, HiddenDirectoryNames: []string{".siyuan"},
PathFilter: func(info os.FileInfo, absPath string) (bool, error) {
return syncPathFilter(dataDir, info, absPath)
},
})
if err != nil {View on GitHub (pinned to 9f775e8a12)