{"record":{"id":"4fd77b284fb5ff1c","repo":"router-for-me/CLIProxyAPI","slug":"xai-discovery-request-failed-w","errorCode":null,"errorMessage":"xai discovery: request failed: %w","messagePattern":"xai discovery: request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/xai.go","lineNumber":78,"sourceCode":"\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}\n\tvar payload struct {\n\t\tDeviceAuthorizationEndpoint string `json:\"device_authorization_endpoint\"`\n\t\tTokenEndpoint               string `json:\"token_endpoint\"`\n\t}\n\tif err = json.Unmarshal(body, &payload); err != nil {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/xai.go#L60-L96","documentation":"Error \"xai discovery: request failed: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/xai.go:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network connectivity to the xAI discovery endpoint and retry.","Inspect the wrapped error for DNS, TLS, or timeout failures."],"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-15T17:31:12.345Z"}