siyuan-note/siyuan · error

configuration is not initialized

Error message

configuration is not initialized

What it means

persistOAuthCredentialsLocked serializes the in-memory MCP OAuth credential store and writes it into the kernel configuration via model.Conf.SetMCPOAuth. If model.Conf is nil the global configuration has not been bootstrapped, so persistence cannot proceed and the caller's put/remove/mark-rejected operation fails.

Source

Thrown at kernel/mcp/client/oauth_store.go:107

		logging.LogWarnf("mcp oauth: parse credentials failed: %s", err)
		return
	}
	oauthCredentialStore.credentials = data.Credentials
}

func decryptOAuthCredentials(ciphertext string) (decrypted []byte) {
	defer func() {
		if recovered := recover(); recovered != nil {
			logging.LogWarnf("mcp oauth: decrypt credentials failed: %v", recovered)
			decrypted = nil
		}
	}()
	return util.AESDecrypt(ciphertext)
}

func persistOAuthCredentialsLocked() error {
	if model.Conf == nil {
		return fmt.Errorf("configuration is not initialized")
	}
	data, err := json.Marshal(&oauthCredentialData{Credentials: oauthCredentialStore.credentials})
	if err != nil {
		return err
	}
	model.Conf.SetMCPOAuth(util.AESEncrypt(string(data)))
	return nil
}

func getOAuthCredential(serverID, endpoint string) (oauthCredential, bool) {
	oauthCredentialStore.Lock()
	defer oauthCredentialStore.Unlock()
	loadOAuthCredentialsLocked()
	for i := len(oauthCredentialStore.credentials) - 1; i >= 0; i-- {
		credential := oauthCredentialStore.credentials[i]
		credentialEndpoint := credential.Endpoint
		if credentialEndpoint == "" {
			credentialEndpoint = credential.Resource

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Ensure the kernel configuration is loaded (model.Conf initialized) before performing MCP OAuth credential operations
  2. In tests, initialize model.Conf (e.g. conf.NewAppConf or the test bootstrap helper) before calling the credential functions
  3. Call the credential operations only from contexts that run after boot completes

Example fix

// before (test)
putOAuthCredential(ctx, cred) // panics/errors: Conf nil
// after
model.Conf = conf.NewAppConf()
putOAuthCredential(ctx, cred)
Defensive patterns

Strategy: type-guard

Validate before calling

if model.Conf == nil { return errors.New("configuration not loaded yet") }

Type guard

func confReady() bool { return model.Conf != nil }

Try / catch

if err := persistOAuthCredentialsLocked(); err != nil {
    if strings.Contains(err.Error(), "configuration is not initialized") { /* defer or bootstrap conf */ }
}

Prevention

When it happens

Trigger: Calling putOAuthCredential, removeOAuthCredential, or markOAuthCredentialRejected before model.Conf is loaded (e.g. very early in boot, in tests that never initialize the config, or before util.Boot/LoadConf ran).

Common situations: Unit tests that exercise the credential store without initializing the global conf; kernel code paths invoked before configuration load completes.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/5c9d8614d1fa01be. Report an issue: GitHub.