siyuan-note/siyuan · error
configuration is not initialized
Error message
configuration is not initialized
What it means
persistOAuthCredentialsLocked needs the global model.Conf configuration object to persist (encrypted) MCP OAuth credentials, but Conf is nil — the application configuration has not been loaded/initialized yet. Writing the credential store is therefore aborted.
Solutions
- Ensure the kernel/workspace is fully booted (model.Conf loaded) before invoking MCP OAuth credential operations
- In tests, initialize model.Conf (load or create a conf object) in the test setup before touching the credential store
- If running embedded, call the same initialization path as kernel Boot() to populate model.Conf
Example fix
// before putOAuthCredential(cred) // Conf not loaded yet // after model.Conf = conf.NewAppConf() // or complete normal boot first putOAuthCredential(cred)
Defensive patterns
Strategy: validation
Validate before calling
if model.Conf == nil {
return fmt.Errorf("configuration not initialized: complete kernel boot before MCP OAuth operations")
} Try / catch
if err := putOAuthCredential(cred); err != nil {
if strings.Contains(err.Error(), "configuration is not initialized") {
// defer persistence until after boot, or initialize conf now
}
} Prevention
- Sequence MCP OAuth work after Conf loading in startup code
- Initialize model.Conf in test fixtures
- Avoid calling credential APIs from pre-boot hooks
When it happens
Trigger: putOAuthCredential, removeOAuthCredential, or markOAuthCredentialRejected runs before kernel configuration initialization completes (or after it was torn down), reaching persistOAuthCredentialsLocked with model.Conf == nil.
Common situations: An MCP OAuth flow triggered very early during kernel boot before Conf is loaded; tests instantiating the credential store without initializing model.Conf; embedding the kernel without calling the standard workspace boot sequence.
Related errors
- command is required for stdio server
- discover OAuth authorization server
- exchange OAuth authorization code
- mcp oauth authorization required
- OAuth authorization failed
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/5c9d8614d1fa01be.
Report an issue: GitHub.
Appendix: 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.ResourceView on GitHub (pinned to 9f775e8a12)