[log] Add debug logging to GitHub API URL derivation#6043
Merged
lpcox merged 2 commits intoMay 20, 2026
Conversation
Log entry and each switch-case result in deriveAPIFromServerURL so that operators can understand which GitHub API URL resolution path was taken (GitHub.com, GHEC *.ghe.com tenant, or GHES /api/v3 fallback). Also log the default-URL fallback path in DeriveGitHubAPIURL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds debug logging around GitHub API URL derivation to make environment-driven URL resolution easier to diagnose.
Changes:
- Logs fallback behavior in
DeriveGitHubAPIURL. - Logs parsing and branch decisions in
deriveAPIFromServerURL. - Refactors GHEC derived URL construction to log the selected API URL before returning.
Show a summary per file
| File | Description |
|---|---|
internal/envutil/github.go |
Adds debug logs for GitHub API URL derivation and fallback paths. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 3
| } | ||
| return strings.TrimRight(strings.TrimSpace(defaultURL), "/") | ||
| result := strings.TrimRight(strings.TrimSpace(defaultURL), "/") | ||
| logGitHub.Printf("GitHub API URL falling back to provided default: %s", result) |
Comment on lines
+83
to
+91
| logGitHub.Printf("Deriving API URL from server URL: %s", serverURL) | ||
|
|
||
| parsed, err := url.Parse(strings.TrimRight(serverURL, "/")) | ||
| if err != nil || parsed.Host == "" { | ||
| logGitHub.Printf("Failed to parse server URL or empty host: serverURL=%s, err=%v", serverURL, err) | ||
| return "" | ||
| } | ||
| if parsed.Scheme != "http" && parsed.Scheme != "https" { | ||
| logGitHub.Printf("Unsupported scheme in server URL: scheme=%s, serverURL=%s", parsed.Scheme, serverURL) |
Comment on lines
+87
to
+91
| logGitHub.Printf("Failed to parse server URL or empty host: serverURL=%s, err=%v", serverURL, err) | ||
| return "" | ||
| } | ||
| if parsed.Scheme != "http" && parsed.Scheme != "https" { | ||
| logGitHub.Printf("Unsupported scheme in server URL: scheme=%s, serverURL=%s", parsed.Scheme, serverURL) |
Collaborator
|
@copilot address review feedback |
Contributor
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds meaningful debug logging to
internal/envutil/github.gofor thederiveAPIFromServerURLfunction, which previously had no logging despite containing important control-flow decisions.Changes
File:
internal/envutil/github.goNew logging in
deriveAPIFromServerURLhttp/https) is detectedgithub.com→ default API URL*.ghe.comtenant →copilot-api.<tenant>.ghe.com<host>/api/v3New logging in
DeriveGitHubAPIURLdefaultURLWhy this matters
When debugging "why is the gateway using the wrong GitHub API URL?" or "why isn't my GHEC tenant resolving correctly?", operators previously had no visibility into which resolution branch was taken. The new
DEBUG=envutil:*log lines make this transparent.Testing
internal/config(TestFetchAndFixSchema_NetworkError— HTTP 403 network issue) confirmed to be unrelated and present on the base branch.Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
invalidhostthatdoesnotexist12345.comSee Network Configuration for more information.