{"record":{"id":"4cf24c7b45276f0d","repo":"github/github-mcp-server","slug":"failed-to-create-raw-client-w-4cf24c","errorCode":null,"errorMessage":"failed to create raw client: %w","messagePattern":"failed to create raw client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/dependencies.go","lineNumber":382,"sourceCode":"\tgqlClient := githubv4.NewEnterpriseClient(graphqlURL.String(), gqlHTTPClient)\n\treturn gqlClient, nil\n}\n\n// GetRawClient implements ToolDependencies.\nfunc (d *RequestDeps) GetRawClient(ctx context.Context) (*raw.Client, error) {\n\tclient, err := d.GetClient(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trawURL, err := d.apiHosts.RawURL(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get Raw URL: %w\", err)\n\t}\n\n\trawClient, err := raw.NewClient(client, rawURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create raw client: %w\", err)\n\t}\n\n\treturn rawClient, nil\n}\n\n// GetRepoAccessCache implements ToolDependencies.\nfunc (d *RequestDeps) GetRepoAccessCache(ctx context.Context) (*lockdown.RepoAccessCache, error) {\n\tif !d.lockdownMode {\n\t\treturn nil, nil\n\t}\n\n\tgqlClient, err := d.GetGQLClient(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trestClient, err := d.GetClient(ctx)\n\tif err != nil {","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/dependencies.go#L364-L400","documentation":"After resolving the raw URL, GetRawClient calls raw.NewClient(client, rawURL), which internally runs gogithub.NewClient(WithEnterpriseURLs(rawURL.String(), rawURL.String())). If that string cannot be re-parsed as an absolute URL, go-github errors and this wrap is returned. Since rawURL arrives as a parsed *url.URL, failure implies a resolver that produces degenerate URL objects (relative, empty, or scheme-less) or a nil-ish URL whose String() is unusable.","triggerScenarios":"A custom RawURL returning &url.URL{Path: \"/raw/\"} (no scheme/host) so String() yields \"/raw/\"; URLs whose Host contains invalid characters; constructed URL structs with Opaque set producing non-standard strings; a resolver returning a URL built from unvalidated tenant input. The standard utils.APIHost never produces such strings.","commonSituations":"Library integrators building *url.URL literals by hand; string-concatenated raw hosts with unencoded characters; GHES hosts with ports where the authority is dropped (the shipped code explicitly preserves u.Host for this reason); version drift in go-github URL validation.","solutions":["Log rawURL.String() right before client construction to see the exact string go-github rejects","Ensure the resolver returns an absolute URL: scheme https, populated Host, and Path built via JoinPath rather than concatenation","Preserve host:port authorities when deriving raw URLs (mirror newGHESHost's use of u.Host)","Unit-test the resolver: assert u.IsAbs() and u.Host != \"\" for RawURL output before wiring it into RequestDeps"],"exampleFix":"// before\nrawURL := &url.URL{Host: \"raw.example.com\"} // no scheme -> String() = \"raw.example.com\"\nrawClient, err := raw.NewClient(client, rawURL) // WithEnterpriseURLs fails\n\n// after\nrawURL := &url.URL{Scheme: \"https\", Host: host, Path: \"/\"}\nif !rawURL.IsAbs() || rawURL.Host == \"\" {\n\treturn nil, fmt.Errorf(\"raw URL must be absolute: %s\", rawURL)\n}\nrawClient, err := raw.NewClient(client, rawURL)","handlingStrategy":"validation","validationCode":"// reject degenerate URLs before raw.NewClient\nif rawURL == nil || !rawURL.IsAbs() || rawURL.Host == \"\" {\n\treturn fmt.Errorf(\"raw URL must be absolute with a host, got %v\", rawURL)\n}","typeGuard":"func isUsableRawURL(u *url.URL) bool {\n\treturn u != nil && u.IsAbs() && u.Host != \"\" && u.Scheme == \"https\"\n}","tryCatchPattern":"rawClient, err := raw.NewClient(client, rawURL)\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to create raw client: %w\", err) // wrapped go-github url.Parse error\n}","preventionTips":["Construct raw URLs with Scheme+Host fields set; avoid Opaque or path-only URLs","Preserve host:port authorities when deriving from a GHES base URL","Unit-test resolver output with u.IsAbs() assertions"],"tags":["go","url-parsing","raw-content","client-construction"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}