{"record":{"id":"63f587126c6aa458","repo":"router-for-me/CLIProxyAPI","slug":"xai-discovery-create-request-w","errorCode":null,"errorMessage":"xai discovery: create request: %w","messagePattern":"xai discovery: create request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/xai.go","lineNumber":73,"sourceCode":"\t}\n\tif parsed.Scheme != \"https\" {\n\t\treturn \"\", fmt.Errorf(\"xai discovery %s must use https: %q\", field, rawURL)\n\t}\n\thost := strings.ToLower(strings.TrimSpace(parsed.Hostname()))\n\tif host != \"x.ai\" && !strings.HasSuffix(host, \".x.ai\") {\n\t\treturn \"\", fmt.Errorf(\"xai discovery %s host %q is not on x.ai\", field, host)\n\t}\n\treturn rawURL, nil\n}\n\n// Discover resolves xAI OAuth endpoints through OIDC discovery.\nfunc (a *XAIAuth) Discover(ctx context.Context) (*Discovery, error) {\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, DiscoveryURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"xai discovery: create request: %w\", err)\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\tresp, err := a.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"xai discovery: request failed: %w\", err)\n\t}\n\tdefer func() {\n\t\tif errClose := resp.Body.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"xai discovery: close response body error: %v\", errClose)\n\t\t}\n\t}()\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"xai discovery: read response: %w\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"xai discovery failed with status %d: %s\", resp.StatusCode, strings.TrimSpace(string(body)))\n\t}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/xai.go#L55-L91","documentation":"Error \"xai discovery: create request: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/xai.go:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the discovery URL is valid and the HTTP client is initialized.","Check the wrapped error for request construction details."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}