{"record":{"id":"68cffc2ca86795f0","repo":"github/github-mcp-server","slug":"failed-to-create-oauth-handler-w","errorCode":null,"errorMessage":"failed to create OAuth handler: %w","messagePattern":"failed to create OAuth handler: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/http/server.go","lineNumber":185,"sourceCode":"\n\t// Register OAuth protected resource metadata endpoints\n\toauthCfg := &oauth.Config{\n\t\tBaseURL:           cfg.BaseURL,\n\t\tResourcePath:      cfg.ResourcePath,\n\t\tTrustProxyHeaders: cfg.TrustProxyHeaders,\n\t}\n\n\tserverOptions := []HandlerOption{}\n\tif cfg.ScopeChallenge {\n\t\tscopeFetcher := scopes.NewFetcher(apiHost, scopes.FetcherOptions{})\n\t\tserverOptions = append(serverOptions, WithScopeFetcher(scopeFetcher))\n\t}\n\n\tr := chi.NewRouter()\n\thandler := NewHTTPMcpHandler(ctx, &cfg, deps, t, logger, apiHost, append(serverOptions, WithFeatureChecker(featureChecker), WithOAuthConfig(oauthCfg))...)\n\toauthHandler, err := oauth.NewAuthHandler(oauthCfg, apiHost)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create OAuth handler: %w\", err)\n\t}\n\n\tr.Group(func(r chi.Router) {\n\t\tr.Use(middleware.SetCorsHeaders)\n\n\t\t// Register Middleware First, needs to be before route registration\n\t\thandler.RegisterMiddleware(r)\n\n\t\t// Register MCP server routes\n\t\thandler.RegisterRoutes(r)\n\t})\n\tlogger.Info(\"MCP endpoints registered\", \"baseURL\", cfg.BaseURL)\n\n\tr.Group(func(r chi.Router) {\n\t\t// Register OAuth protected resource metadata endpoints\n\t\toauthHandler.RegisterRoutes(r)\n\t})\n\tlogger.Info(\"OAuth protected resource endpoints registered\", \"baseURL\", cfg.BaseURL)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/http/server.go#L167-L203","documentation":"oauth.NewAuthHandler(cfg, apiHost) failed while constructing the OAuth protected-resource metadata handler. Internally it only errors when the apiHost resolver is nil and the hardcoded default host fails to parse - but RunHTTPServer already parsed apiHost successfully at startup, so this branch is effectively unreachable defensive error wrapping.","triggerScenarios":"A fork or refactor changes NewAuthHandler to validate the passed resolver and the resolver construction fails; passing a nil apiHost in a build where the default constant is invalid.","commonSituations":"Custom deployments altering OAuth handler construction; refactor drift between the server and the oauth package.","solutions":["Reuse the apiHost resolved early in RunHTTPServer (as the current code does) instead of nil","Keep NewAuthHandler's default host constant a valid URL","Add a startup test that constructs the OAuth handler with the production config"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if apiHost == nil {\n\treturn fmt.Errorf(\"cannot create OAuth handler without an API host resolver\")\n}\noauthHandler, err := oauth.NewAuthHandler(oauthCfg, apiHost)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct the apiHost once at startup and pass it everywhere","Smoke-test OAuth handler construction with production config in CI","Keep default host constants valid absolute URLs"],"tags":["oauth","configuration","startup"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}