From f4fb2e89bf1063598c4a1687735b827fb0028010 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Jun 2026 23:49:20 +0000 Subject: [PATCH 1/2] Add debug logging to urlutil/domains.go Add logDomains debug logger (urlutil:domains namespace) and 4 meaningful log calls to ExtractURLDomains and ExtractURLDomainsFromValue: - Log URL candidate count found by regex - Log unparseable URL candidates (for troubleshooting regex edge cases) - Log final unique domain count resolved from candidates - Log when no domains are found in the value tree Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/urlutil/domains.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/urlutil/domains.go b/internal/urlutil/domains.go index 502c4f59..600ac2c0 100644 --- a/internal/urlutil/domains.go +++ b/internal/urlutil/domains.go @@ -5,8 +5,12 @@ import ( "regexp" "sort" "strings" + + "github.com/github/gh-aw-mcpg/internal/logger" ) +var logDomains = logger.New("urlutil:domains") + // urlPattern requires a non-empty hostname candidate and then captures the rest // of the URL until common delimiter characters. The (?i) flag makes the scheme // match case-insensitive (e.g. "HTTPS://"). Matches are still validated with @@ -18,6 +22,7 @@ func ExtractURLDomainsFromValue(value any) []string { domainSet := make(map[string]struct{}) collectURLDomains(value, domainSet) if len(domainSet) == 0 { + logDomains.Print("ExtractURLDomainsFromValue: no domains found in value tree") return nil } @@ -26,6 +31,7 @@ func ExtractURLDomainsFromValue(value any) []string { domains = append(domains, domain) } sort.Strings(domains) + logDomains.Printf("ExtractURLDomainsFromValue: extracted %d unique domain(s)", len(domains)) return domains } @@ -56,6 +62,7 @@ func ExtractURLDomains(text string) []string { if len(matches) == 0 { return nil } + logDomains.Printf("ExtractURLDomains: found %d URL candidate(s) in text", len(matches)) domainSet := make(map[string]struct{}) for _, match := range matches { @@ -67,6 +74,7 @@ func ExtractURLDomains(text string) []string { match = strings.TrimRight(match, ".,;:!?)]}\"'") parsed, err := url.Parse(match) if err != nil { + logDomains.Printf("ExtractURLDomains: skipping unparseable URL candidate: %v", err) continue } host := strings.ToLower(parsed.Hostname()) @@ -84,5 +92,6 @@ func ExtractURLDomains(text string) []string { domains = append(domains, domain) } sort.Strings(domains) + logDomains.Printf("ExtractURLDomains: resolved %d unique domain(s) from %d candidate(s)", len(domains), len(matches)) return domains } From 83356b5bed21c2bf2d7e2957bec2978438d6a5dc Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Tue, 23 Jun 2026 16:53:42 -0700 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- internal/urlutil/domains.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/urlutil/domains.go b/internal/urlutil/domains.go index 600ac2c0..e826e2de 100644 --- a/internal/urlutil/domains.go +++ b/internal/urlutil/domains.go @@ -74,7 +74,11 @@ func ExtractURLDomains(text string) []string { match = strings.TrimRight(match, ".,;:!?)]}\"'") parsed, err := url.Parse(match) if err != nil { - logDomains.Printf("ExtractURLDomains: skipping unparseable URL candidate: %v", err) + if uerr, ok := err.(*url.Error); ok { + logDomains.Printf("ExtractURLDomains: skipping unparseable URL candidate: %v", uerr.Err) + } else { + logDomains.Printf("ExtractURLDomains: skipping unparseable URL candidate (%T)", err) + } continue } host := strings.ToLower(parsed.Hostname())