{"record":{"id":"6ddb45d103b427f9","repo":"siyuan-note/siyuan","slug":"oidc-configuration-is-missing","errorCode":null,"errorMessage":"OIDC configuration is missing","messagePattern":"OIDC configuration is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/oidc_provider/provider.go","lineNumber":37,"sourceCode":"\n\t\"github.com/coreos/go-oidc/v3/oidc\"\n\t\"github.com/siyuan-note/siyuan/kernel/conf\"\n\t\"golang.org/x/oauth2\"\n)\n\nconst (\n\tgoogleIssuer = \"https://accounts.google.com\"\n)\n\ntype Provider struct {\n\tkind         string\n\toauth2Config *oauth2.Config\n\tverifier     *oidc.IDTokenVerifier\n}\n\nfunc New(ctx context.Context, config *conf.OIDC, redirectURL string) (*Provider, error) {\n\tif config == nil {\n\t\treturn nil, errors.New(\"OIDC configuration is missing\")\n\t}\n\tif config.ClientID == \"\" {\n\t\treturn nil, errors.New(\"OIDC client ID is required\")\n\t}\n\tif redirectURL == \"\" {\n\t\treturn nil, errors.New(\"OIDC redirect URL is required\")\n\t}\n\tif config.Provider == conf.OIDCProviderGitHub && config.ClientSecret == \"\" {\n\t\treturn nil, errors.New(\"GitHub OAuth client secret is required\")\n\t}\n\tissuerURL := strings.TrimSpace(config.IssuerURL)\n\tswitch config.Provider {\n\tcase conf.OIDCProviderGoogle:\n\t\tissuerURL = googleIssuer\n\tcase conf.OIDCProviderMicrosoft:\n\t\t// Microsoft 多租户端点的 issuer 会随租户变化，必须使用租户专属 issuer。\n\tcase conf.OIDCProviderCustom:\n\tcase conf.OIDCProviderGitHub:","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/oidc_provider/provider.go#L19-L55","documentation":"Thrown by oidc_provider.New() when the config argument is nil. This is the first guard in the OIDC provider constructor, firing before any field validation. The OIDC subsystem requires a populated *conf.OIDC to build an OAuth2 config and verifier; a nil pointer means the caller never initialized or loaded the OIDC settings from the SiYuan configuration.","triggerScenarios":"Calling oidc_provider.New(ctx, nil, redirectURL) — the entire config struct is nil. This happens when the API layer reads conf.OIDC and it was never set, or when a code path forwards the pointer without checking intermediate nil fields (e.g., Conf.OIDC itself is nil).","commonSituations":"The administrator has not configured any OIDC provider in settings but the feature was triggered anyway (e.g., a user navigates to the SSO login endpoint). A migration or config reset left the OIDC section empty. The API handler dereferences Conf.OIDC without a nil-check before calling New().","solutions":["Ensure conf.OIDC is populated in the SiYuan settings before any OIDC login flow is reachable.","In the calling code, add a nil-check on Conf.OIDC before invoking New() and return a user-friendly 'OIDC not configured' HTTP error.","If OIDC is optional, gate the endpoint registration on Conf.OIDC != nil at server startup so the route is never exposed."],"exampleFix":"// before\nprovider, err := oidc_provider.New(ctx, Conf.OIDC, redirectURL)\n\n// after\nif Conf.OIDC == nil {\n    http.Error(w, \"OIDC not configured\", http.StatusServiceUnavailable)\n    return\n}\nprovider, err := oidc_provider.New(ctx, Conf.OIDC, redirectURL)","handlingStrategy":"validation","validationCode":"if config == nil {\n    return nil, errors.New(\"OIDC is not configured; set up an OIDC provider in Settings first\")\n}\nprovider, err := oidc_provider.New(ctx, config, redirectURL)","typeGuard":"func isOIDCConfigured(c *conf.OIDC) bool {\n    return c != nil\n}","tryCatchPattern":null,"preventionTips":["Gate OIDC endpoint registration on Conf.OIDC != nil at server startup.","In API handlers, always nil-check Conf.OIDC before calling New().","Return a 503 Service Unavailable with a descriptive message if OIDC is not configured."],"tags":["oidc","authentication","config","nil-guard"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}