From 0e2d73c763c7c37af0b0686eb7f61e1b4dec357e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2026 05:13:14 +0000 Subject: [PATCH] Add debug logging to unified server utility functions Add logUnified debug logging calls to utility functions in internal/server/unified.go that previously had no debug visibility: - lookupEnrichmentToken: logs which env var provided the token, or that no token was found across all checked env vars - lookupGitHubAPIBaseURL: logs whether a custom GITHUB_API_URL is in use or the default api.github.com is being used - buildAllowedToolSets: logs per-server tool restriction counts and the total number of servers with tool restrictions configured - GetToolsForBackend: logs how many tools were found for the requested backend ID These additions make it easier to troubleshoot token resolution, API URL routing, tool allowlist configuration, and backend tool discovery at runtime with DEBUG=server:* enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/server/unified.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/server/unified.go b/internal/server/unified.go index ecf30c46..52b35094 100644 --- a/internal/server/unified.go +++ b/internal/server/unified.go @@ -350,9 +350,11 @@ func lookupEnrichmentToken() string { "GH_TOKEN", } { if v := strings.TrimSpace(os.Getenv(key)); v != "" { + logUnified.Printf("Found enrichment token in env var: %s", key) return v } } + logUnified.Print("No enrichment token found in any env var") return "" } @@ -360,8 +362,11 @@ func lookupEnrichmentToken() string { // or defaults to https://api.github.com. func lookupGitHubAPIBaseURL() string { if v := os.Getenv("GITHUB_API_URL"); v != "" { - return strings.TrimRight(v, "/") + url := strings.TrimRight(v, "/") + logUnified.Printf("Using custom GitHub API URL from GITHUB_API_URL: %s", url) + return url } + logUnified.Print("Using default GitHub API URL: https://api.github.com") return "https://api.github.com" } @@ -391,8 +396,10 @@ func buildAllowedToolSets(cfg *config.Config) map[string]map[string]bool { set[t] = true } sets[serverID] = set + logUnified.Printf("Built allowed tool set for server %s: %d tool(s) permitted", serverID, len(set)) } } + logUnified.Printf("Built allowed tool sets: %d server(s) with tool restrictions", len(sets)) return sets } @@ -714,6 +721,7 @@ func (us *UnifiedServer) GetToolsForBackend(backendID string) []ToolInfo { } } + logUnified.Printf("GetToolsForBackend: backendID=%s, found=%d tools", backendID, len(filtered)) return filtered }