siyuan-note/siyuan · error

invalid provider [%d]

Error message

invalid provider [%d]

What it means

buildCloudConf() assembles the provider-specific cloud configuration from the same switch; an out-of-range Conf.Sync.Provider reaches the default branch and returns fmt.Errorf("invalid provider [%d]", ...). It fails earlier than newRepository's client construction, so most sync paths surface this message first when the provider value is bad.

Source

Thrown at kernel/model/repository.go:3001

			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 afa823b6b4)

Solutions

  1. Re-select the provider in Settings - Account & Sync so the kernel rewrites a valid provider id
  2. Fix workspace/conf.json manually: set sync.provider to 0 (SiYuan), 2 (S3), 3 (WebDAV), or 4 (local) and restart
  3. Check for plugins/tools that mutate sync settings and remove or update them

Example fix

// before
if err := model.SyncData(true); err != nil { /* invalid provider [7] */ }

// after: normalize before use
if p := model.Conf.Sync.Provider; p != 0 && p != 2 && p != 3 && p != 4 {
    model.Conf.Sync.Provider = 0 // default to official cloud, then reconfigure in UI
}
err := model.SyncData(true)
Defensive patterns

Strategy: validation

Validate before calling

switch model.Conf.Sync.Provider {
case 0, 2, 3, 4:
    // ok
default:
    return errors.New("invalid sync provider; fix conf.json or re-select in Settings")
}
_, err := model.GetCloudSpace()

Type guard

func isValidSyncProvider(p int) bool {
    return p >= 0 && p <= 4 && p != 1 // 1 is a removed legacy id
}

Prevention

When it happens

Trigger: Any call that needs cloud credentials — newSyncRepository, GetCloudSpace, backup/sync setup — while Conf.Sync.Provider is not 0/2/3/4 (kernel/model/repository.go:3001). Typically the same corrupted conf.json as the sibling 'unknown cloud provider' error.

Common situations: Hand-edited or migrated conf.json; a fork or plugin writing an unsupported provider id; downgrade to a version that dropped a legacy provider.

Related errors


AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18). Data as JSON: /api/errors/5ccc13eb28dbf488. Report an issue: GitHub.