{"record":{"id":"ed2ca83b20c85685","repo":"siyuan-note/siyuan","slug":"unknown-cloud-provider-d","errorCode":null,"errorMessage":"unknown cloud provider [%d]","messagePattern":"unknown cloud provider \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":3014,"sourceCode":"\t\tcloudRepo = cloud.NewSiYuan(&cloud.BaseCloud{Conf: cloudConf})\n\tcase conf.ProviderS3:\n\t\t// 显式注入 SiYuan UA，覆盖 aws SDK 默认 UA（含架构、Go 版本、SDK 版本等冗余信息），便于 S3 服务端按 SiYuan/ 前缀识别加白名单\n\t\ts3HTTPClient := httpclient.NewUserAgentClient(httpclient.NewTransport(cloudConf.S3.SkipTlsVerify))\n\t\ts3HTTPClient.Timeout = time.Duration(cloudConf.S3.Timeout) * time.Second\n\t\tcloudRepo = cloud.NewS3(&cloud.BaseCloud{Conf: cloudConf}, s3HTTPClient)\n\tcase conf.ProviderWebDAV:\n\t\twebdavClient := gowebdav.NewClient(cloudConf.WebDAV.Endpoint, cloudConf.WebDAV.Username, cloudConf.WebDAV.Password)\n\t\ta := cloudConf.WebDAV.Username + \":\" + cloudConf.WebDAV.Password\n\t\tauth := \"Basic \" + base64.StdEncoding.EncodeToString([]byte(a))\n\t\twebdavClient.SetHeader(\"Authorization\", auth)\n\t\twebdavClient.SetHeader(\"User-Agent\", util.UserAgent)\n\t\twebdavClient.SetTimeout(time.Duration(cloudConf.WebDAV.Timeout) * time.Second)\n\t\twebdavClient.SetTransport(httpclient.NewTransport(cloudConf.WebDAV.SkipTlsVerify))\n\t\tcloudRepo = cloud.NewWebDAV(&cloud.BaseCloud{Conf: cloudConf}, webdavClient)\n\tcase conf.ProviderLocal:\n\t\tcloudRepo = cloud.NewLocal(&cloud.BaseCloud{Conf: cloudConf})\n\tdefault:\n\t\terr = fmt.Errorf(\"unknown cloud provider [%d]\", Conf.Sync.Provider)\n\t\treturn\n\t}\n\n\tignoreLines, err := getSyncIgnoreLines()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdataDir := util.DataDir\n\tret, err = dejavu.NewRepoWithOptions(dejavu.Options{\n\t\tDataPath: util.DataDir, RepoPath: util.RepoDir, HistoryPath: util.HistoryDir, TempPath: util.TempDir,\n\t\tDeviceID: Conf.System.ID, DeviceName: Conf.System.Name, DeviceOS: Conf.System.OS,\n\t\tAESKey: Conf.Repo.Key, IgnoreLines: ignoreLines, Cloud: cloudRepo,\n\t\tIgnoreRulePath: syncIgnoreRulePath, HiddenDirectoryNames: []string{\".siyuan\"},\n\t\tPathFilter: func(info os.FileInfo, absPath string) (bool, error) {\n\t\t\treturn syncPathFilter(dataDir, info, absPath)\n\t\t},\n\t})\n\tif err != nil {","sourceCodeStart":2996,"sourceCodeEnd":3032,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/repository.go#L2996-L3032","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before (hand-edited conf.json)\n\"sync\": { \"provider\": 9 }\n// after\n\"sync\": { \"provider\": 3, \"webdav\": { \"endpoint\": \"https://dav.example.com\", ... } }","handlingStrategy":"validation","validationCode":"const VALID = new Set([2, 3, 4]); // S3, WebDAV, Local per conf package\nconst conf = (await (await fetch('/api/system/getConf', {method:'POST'})).json()).data;\nif (!VALID.has(conf.sync?.provider)) throw new Error('sync.provider is not a supported cloud provider: ' + conf.sync?.provider);","typeGuard":"function isValidProvider(p) { return p === 2 || p === 3 || p === 4; } // S3 | WebDAV | Local","tryCatchPattern":"try {\n  await startSync();\n} catch (e) {\n  const m = /unknown cloud provider \\[(\\d+)\\]/.exec(e.message);\n  if (m) { await resetProviderToKnownGood(Number(m[1])); }\n  else throw e;\n}","preventionTips":["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"],"tags":["sync","configuration","enum","provider"],"backgroundTag":"invalid-enum-value","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}