{"record":{"id":"b355044bdfc3432b","repo":"router-for-me/CLIProxyAPI","slug":"xai-discovery-s-host-q-is-not-on-x-ai","errorCode":null,"errorMessage":"xai discovery %s host %q is not on x.ai","messagePattern":"xai discovery (.+?) host %q is not on x\\.ai","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/xai.go","lineNumber":61,"sourceCode":"\treturn &XAIAuth{httpClient: util.SetProxy(&sdkCfg, &http.Client{Timeout: httpClientTimeout})}\n}\n\n// ValidateOAuthEndpoint validates an endpoint returned by xAI discovery.\nfunc ValidateOAuthEndpoint(rawURL string, field string) (string, error) {\n\trawURL = strings.TrimSpace(rawURL)\n\tif rawURL == \"\" {\n\t\treturn \"\", fmt.Errorf(\"xai discovery %s is empty\", field)\n\t}\n\tparsed, err := url.Parse(rawURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"xai discovery %s is invalid: %w\", field, err)\n\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}","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/xai.go#L43-L79","documentation":"Error \"xai discovery %s host %q is not on x.ai\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/xai.go:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Point the discovery endpoint at an official x.ai host.","Reject custom or proxy hosts not under x.ai in configuration."],"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"}