siyuan-note/siyuan · error

invalid provider [ ]

Error message

invalid provider [%d]

What it means

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.

Solutions

  1. Reselect the cloud provider in Settings - Account & Sync so the enum is set to a supported value
  2. Check conf.json: set sync.provider to a valid constant (S3/WebDAV/Local per conf package)
  3. Apply provider changes through /api/system/setConf rather than direct file edits on a running kernel
  4. Restore the workspace conf from a known-good backup if the enum was corrupted

Example fix

// before
"sync": { "provider": 0 }  // unsupported value
// after (WebDAV example)
"sync": { "provider": 3, "webdav": { "endpoint": "https://dav.example.com", "username": "u", "password": "p", "timeout": 30 } }
Defensive patterns

Strategy: type-guard

Validate before calling

function providerIsSupported(n) { return [2, 3, 4].includes(n); }
const conf = (await (await fetch('/api/system/getConf', {method:'POST'})).json()).data;
if (!providerIsSupported(conf.sync?.provider)) throw new Error('Invalid sync provider: ' + conf.sync?.provider);

Type guard

const isProvider = (v) => v === 2 /*S3*/ || v === 3 /*WebDAV*/ || v === 4 /*Local*/;

Try / catch

try {
  await verifyCloudSettings();
} catch (e) {
  const m = /invalid provider \[(\d+)\]/.exec(e.message);
  if (m) await setConf({sync: {provider: 3}}); // fall back to a known provider
  else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/5ccc13eb28dbf488. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/repository.go:3326

			ConcurrentReqs: Conf.Sync.S3.ConcurrentReqs,
		}
	case conf.ProviderWebDAV:
		ret.WebDAV = &cloud.ConfWebDAV{
			Endpoint:       Conf.Sync.WebDAV.Endpoint,
			Username:       Conf.Sync.WebDAV.Username,
			Password:       Conf.Sync.WebDAV.Password,
			SkipTlsVerify:  Conf.Sync.WebDAV.SkipTlsVerify,
			Timeout:        Conf.Sync.WebDAV.Timeout,
			ConcurrentReqs: Conf.Sync.WebDAV.ConcurrentReqs,
		}
	case conf.ProviderLocal:
		ret.Local = &cloud.ConfLocal{
			Endpoint:       Conf.Sync.Local.Endpoint,
			Timeout:        Conf.Sync.Local.Timeout,
			ConcurrentReqs: Conf.Sync.Local.ConcurrentReqs,
		}
	default:
		err = fmt.Errorf("invalid provider [%d]", Conf.Sync.Provider)
		return
	}
	return
}

type Backup struct {
	Size    int64  `json:"size"`
	HSize   string `json:"hSize"`
	Updated string `json:"updated"`
	SaveDir string `json:"saveDir"` // 本地备份数据存放目录路径
}

type Sync struct {
	Size      int64  `json:"size"`
	HSize     string `json:"hSize"`
	Updated   string `json:"updated"`
	CloudName string `json:"cloudName"` // 云端同步数据存放目录名
	SaveDir   string `json:"saveDir"`   // 本地同步数据存放目录路径

View on GitHub (pinned to 9f775e8a12)