{"record":{"id":"5ccc13eb28dbf488","repo":"siyuan-note/siyuan","slug":"invalid-provider-d","errorCode":null,"errorMessage":"invalid provider [%d]","messagePattern":"invalid provider \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":3326,"sourceCode":"\t\t\tConcurrentReqs: Conf.Sync.S3.ConcurrentReqs,\n\t\t}\n\tcase conf.ProviderWebDAV:\n\t\tret.WebDAV = &cloud.ConfWebDAV{\n\t\t\tEndpoint:       Conf.Sync.WebDAV.Endpoint,\n\t\t\tUsername:       Conf.Sync.WebDAV.Username,\n\t\t\tPassword:       Conf.Sync.WebDAV.Password,\n\t\t\tSkipTlsVerify:  Conf.Sync.WebDAV.SkipTlsVerify,\n\t\t\tTimeout:        Conf.Sync.WebDAV.Timeout,\n\t\t\tConcurrentReqs: Conf.Sync.WebDAV.ConcurrentReqs,\n\t\t}\n\tcase conf.ProviderLocal:\n\t\tret.Local = &cloud.ConfLocal{\n\t\t\tEndpoint:       Conf.Sync.Local.Endpoint,\n\t\t\tTimeout:        Conf.Sync.Local.Timeout,\n\t\t\tConcurrentReqs: Conf.Sync.Local.ConcurrentReqs,\n\t\t}\n\tdefault:\n\t\terr = fmt.Errorf(\"invalid provider [%d]\", Conf.Sync.Provider)\n\t\treturn\n\t}\n\treturn\n}\n\ntype Backup struct {\n\tSize    int64  `json:\"size\"`\n\tHSize   string `json:\"hSize\"`\n\tUpdated string `json:\"updated\"`\n\tSaveDir string `json:\"saveDir\"` // 本地备份数据存放目录路径\n}\n\ntype Sync struct {\n\tSize      int64  `json:\"size\"`\n\tHSize     string `json:\"hSize\"`\n\tUpdated   string `json:\"updated\"`\n\tCloudName string `json:\"cloudName\"` // 云端同步数据存放目录名\n\tSaveDir   string `json:\"saveDir\"`   // 本地同步数据存放目录路径","sourceCodeStart":3308,"sourceCodeEnd":3344,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/repository.go#L3308-L3344","documentation":"The cloud conf builder (getCloudConf / buildCloudConf) converts Conf.Sync.Provider into the concrete provider config struct (S3/WebDAV/Local). A default branch catches any provider value outside the supported set and returns fmt.Errorf(\"invalid provider [%d]\"). Unlike error 1747 (client construction), this fires earlier when building the provider's configuration object, e.g. when verifying cloud settings or fetching cloud conf.","triggerScenarios":"Any API that builds the cloud provider configuration (cloud conf verification, sync setup, GetCloudSpace chain) while Conf.Sync.Provider is not one of the supported provider constants.","commonSituations":"conf.json manually edited with an unknown provider number; config restored from a different SiYuan version; external script/plugin setting Sync.Provider; corrupted workspace configuration.","solutions":["Reselect the cloud provider in Settings - Account & Sync so the enum is set to a supported value","Check conf.json: set sync.provider to a valid constant (S3/WebDAV/Local per conf package)","Apply provider changes through /api/system/setConf rather than direct file edits on a running kernel","Restore the workspace conf from a known-good backup if the enum was corrupted"],"exampleFix":"// before\n\"sync\": { \"provider\": 0 }  // unsupported value\n// after (WebDAV example)\n\"sync\": { \"provider\": 3, \"webdav\": { \"endpoint\": \"https://dav.example.com\", \"username\": \"u\", \"password\": \"p\", \"timeout\": 30 } }","handlingStrategy":"type-guard","validationCode":"function providerIsSupported(n) { return [2, 3, 4].includes(n); }\nconst conf = (await (await fetch('/api/system/getConf', {method:'POST'})).json()).data;\nif (!providerIsSupported(conf.sync?.provider)) throw new Error('Invalid sync provider: ' + conf.sync?.provider);","typeGuard":"const isProvider = (v) => v === 2 /*S3*/ || v === 3 /*WebDAV*/ || v === 4 /*Local*/;","tryCatchPattern":"try {\n  await verifyCloudSettings();\n} catch (e) {\n  const m = /invalid provider \\[(\\d+)\\]/.exec(e.message);\n  if (m) await setConf({sync: {provider: 3}}); // fall back to a known provider\n  else throw e;\n}","preventionTips":["Set sync.provider exclusively via the settings UI or setConf API","Re-validate configuration after version downgrades/upgrades of the workspace","Never write raw enum values from undocumented sources","Keep a known-good conf.json backup to restore from"],"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"}