Skip to content

Commit aa6afa6

Browse files
fix: prevent nil pointer panic when OAuthManager interface contains nil
Go interface nil check fails when a typed nil pointer is assigned to an interface - the interface itself is non-nil but contains a nil value. This caused a panic when OAuth credentials weren't configured. Fix by only assigning OAuthManager after confirming oauthMgr is not nil.
1 parent 554e0fb commit aa6afa6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd/github-mcp-server/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ var (
109109
Version: version,
110110
Host: viper.GetString("host"),
111111
Token: token,
112-
OAuthManager: oauthMgr,
113112
OAuthScopes: oauthScopes,
114113
PrebuiltInventory: prebuiltInventory,
115114
EnabledToolsets: enabledToolsets,
@@ -125,6 +124,11 @@ var (
125124
InsiderMode: viper.GetBool("insider-mode"),
126125
RepoAccessCacheTTL: &ttl,
127126
}
127+
// Only set OAuthManager if not nil - interface nil check requires this pattern
128+
// to avoid a non-nil interface containing a nil pointer
129+
if oauthMgr != nil {
130+
stdioServerConfig.OAuthManager = oauthMgr
131+
}
128132
return ghmcp.RunStdioServer(stdioServerConfig)
129133
},
130134
}

0 commit comments

Comments
 (0)