siyuan-note/siyuan · error
save OAuth client registration: %w
Error message
save OAuth client registration: %w
What it means
Wrapped error at oauth.go:334-335 when putOAuthCredential fails to persist the freshly registered client credential (client_id, secret, endpoints, scopes). The registration itself succeeded but local storage (keystore backing oauthCredential) rejected the write.
Source
Thrown at kernel/mcp/client/oauth.go:335
ClientSecret: registration.ClientSecret,
ClientSecretExpiry: registration.ClientSecretExpiresAt,
TokenEndpoint: asm.TokenEndpoint,
RevocationEndpoint: asm.RevocationEndpoint,
TokenAuthMethod: registration.TokenEndpointAuthMethod,
Scopes: scopes,
}
if registrationCredential.TokenAuthMethod == "" {
if registration.ClientSecret == "" {
registrationCredential.TokenAuthMethod = "none"
} else {
registrationCredential.TokenAuthMethod = "client_secret_basic"
}
}
if !isSupportedTokenAuthMethod(registrationCredential.TokenAuthMethod) {
return fmt.Errorf("OAuth client registration returned an unsupported token endpoint authentication method")
}
if err = putOAuthCredential(registrationCredential); err != nil {
return fmt.Errorf("save OAuth client registration: %w", err)
}
}
authMethod := registrationCredential.TokenAuthMethod
if authMethod == "" {
if registrationCredential.ClientSecret == "" {
authMethod = "none"
} else {
authMethod = "client_secret_basic"
}
}
config := &oauth2.Config{
ClientID: registrationCredential.ClientID,
ClientSecret: registrationCredential.ClientSecret,
RedirectURL: callbackURL,
Scopes: scopes,
Endpoint: oauth2.Endpoint{
AuthURL: asm.AuthorizationEndpoint,View on GitHub (pinned to 251596fc0d)
Solutions
- Check the wrapped error (file system errno) and free space / fix permissions on the kernel data directory.
- Ensure no other SiYuan process holds the workspace lock (single-instance requirement).
- Retry the authorization once the storage issue is resolved; the AS registration is still valid until it expires, but SiYuan must re-register because the save failed.
Defensive patterns
Strategy: try-catch
Try / catch
if err = putOAuthCredential(registrationCredential); err != nil {
// Error 327: registration succeeded locally but persistence failed.
logging.LogErrorf("mcp oauth: persist registration failed: %s", err)
return fmt.Errorf("save OAuth client registration: %w", err)
} Prevention
- Keep the kernel data directory writable and with adequate free space.
- Run a single SiYuan instance per workspace to avoid keystore lock contention.
- Monitor for filesystem errors in logs to catch persistent storage degradation early.
When it happens
Trigger: putOAuthCredential returns a non-nil error immediately after a successful RegisterClient and the TokenAuthMethod validation passed. Subsequent calls will re-attempt registration because nothing was saved.
Common situations: Disk full or permission denied on the keystore file; workspace data directory not writable; keystore JSON corruption that fails to serialize; antivirus/file-lock on Windows locking the credential file.
Related errors
- save OAuth credentials: %w
- mcp oauth authorization required
- parse OAuth challenge: %w
- server returned %s without an OAuth Bearer challenge
- server returned %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/3512a79dc8c2fb28.
Report an issue: GitHub.