{"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":2711,"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 := getSyncIgnoreLines()\n\tignoreLines = append(ignoreLines, \"/.siyuan/conf.json\") // 忽略旧版同步配置\n\tret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.System.ID, Conf.System.Name, Conf.System.OS, Conf.Repo.Key, ignoreLines, cloudRepo)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"init data repo failed: %s\", err)\n\t\treturn\n\t}\n\treturn\n}\n\nfunc init() {\n\tsubscribeRepoEvents()\n}\n\nfunc subscribeRepoEvents() {","sourceCodeStart":2693,"sourceCodeEnd":2729,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/repository.go#L2693-L2729","documentation":"newRepository() builds the cloud-backed dejavu repo client from a switch on Conf.Sync.Provider. Valid values are 0 (official SiYuan cloud), 2 (S3), 3 (WebDAV), 4 (local directory); anything else hits the default branch and returns fmt.Errorf(\"unknown cloud provider [%d]\", ...). This indicates a corrupted or out-of-range provider value in conf.json.","triggerScenarios":"Conf.Sync.Provider holds a value not in {0,2,3,4} when newRepository() runs — e.g. hand-edited workspace conf.json, a config written by a different SiYuan version or fork, or value 1 (a removed legacy provider id) carried over from an old config (kernel/model/repository.go:2711).","commonSituations":"Manual conf.json edits; syncing a workspace between versions whose provider enum changed; third-party tools writing sync settings; restored config from an incompatible backup.","solutions":["Open Settings - Account & Sync and re-select a valid cloud provider (SiYuan/S3/WebDAV/Local), which rewrites conf.sync.provider","Or edit workspace/conf.json and set sync.provider to 0, 2, 3, or 4, then restart the kernel","Avoid third-party tools that write sync config; after restoring backups, re-validate provider settings in the UI"],"exampleFix":"// before: conf.json has \"provider\": 7 inside \"sync\"\n\n// after\n{\n  \"sync\": {\n    \"provider\": 4,\n    \"local\": { \"endpoint\": \"D:/siyuan-sync\" }\n  }\n}","handlingStrategy":"validation","validationCode":"validProviders := map[int]bool{conf.ProviderSiYuan: true, conf.ProviderS3: true, conf.ProviderWebDAV: true, conf.ProviderLocal: true}\nif !validProviders[model.Conf.Sync.Provider] {\n    return errors.New(\"sync.provider in conf.json is invalid; re-select the provider in Settings\")\n}\nrepo, err := model.NewRepository()","typeGuard":"func isValidSyncProvider(p int) bool {\n    return p == 0 || p == 2 || p == 3 || p == 4\n}","tryCatchPattern":null,"preventionTips":["Never hand-edit sync.provider in conf.json; change providers via Settings","After restoring a workspace backup, revalidate sync settings in the UI before syncing","Watch for enum changes when downgrading SiYuan versions"],"tags":["config","sync","provider","enum","siyuan"],"backgroundTag":"invalid-config-enum-value","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}