github/github-mcp-server · warning
internal error
Error message
internal error
What it means
While rendering the OAuth callback success page, successTemplate.Execute returned an error and the handler responds with a bare 500 'internal error' as a last resort. The template is static, pre-parsed, and executed with nil data, so in practice Execute fails because the client disconnected mid-write (broken pipe) - at that point the token exchange has already succeeded. Persistent occurrences would indicate corrupted embedded templates.
Source
Thrown at internal/oauth/callback.go:146
select {
case res := <-cs.results:
return res.code, res.err
case <-ctx.Done():
return "", ctx.Err()
}
}
func (cs *callbackServer) close() {
shutdownCtx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
_ = cs.server.Shutdown(shutdownCtx)
_ = cs.listener.Close()
}
func renderSuccess(w http.ResponseWriter) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := successTemplate.Execute(w, nil); err != nil {
http.Error(w, "internal error", http.StatusInternalServerError)
}
}
// renderError shows the failure page. html/template auto-escapes msg, so a
// hostile error_description cannot inject markup.
func renderError(w http.ResponseWriter, msg string) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := errorTemplate.Execute(w, struct{ ErrorMessage string }{ErrorMessage: msg}); err != nil {
http.Error(w, "internal error", http.StatusInternalServerError)
}
}
View on GitHub (pinned to 0ea1f775a7)
Solutions
- Treat one-off occurrences as benign - the authorization already completed before rendering
- If persistent, rebuild the binary to rule out corrupted embedded templates
- Ensure no middleware writes headers before the callback handler runs
Defensive patterns
Strategy: try-catch
Try / catch
if err := successTemplate.Execute(w, nil); err != nil {
// headers may already be flushed; the 500 fallback is best-effort - log at warn, not error
http.Error(w, "internal error", http.StatusInternalServerError)
} Prevention
- Log template execution failures at warn level - client aborts during OAuth callbacks are routine
- Keep callback responses small so the mid-write abort window is tiny
- Test the callback handler against a client that disconnects mid-read
When it happens
Trigger: User closes the browser tab or the connection drops exactly as the success page streams out at the end of the OAuth flow.
Common situations: End users canceling at the final redirect; mobile browsers backgrounding during callback; scanners hitting the callback URL and disconnecting.
Related errors
- App not connected
- authentication required: set GITHUB_PERSONAL_ACCESS_TOKEN, c
- no authorization code in callback
- failed to download logs: %w
- failed to read response body: %w
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/78a2a6432f61facd.
Report an issue: GitHub.