{"record":{"id":"6f9a20c4d1d9cc1a","repo":"router-for-me/CLIProxyAPI","slug":"xai-discovery-s-is-empty","errorCode":null,"errorMessage":"xai discovery %s is empty","messagePattern":"xai discovery (.+?) is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/xai.go","lineNumber":50,"sourceCode":"// NewXAIAuthWithProxyURL creates an xAI OAuth helper with an explicit proxy URL.\nfunc NewXAIAuthWithProxyURL(cfg *config.Config, proxyURL string) *XAIAuth {\n\teffectiveProxyURL := strings.TrimSpace(proxyURL)\n\tvar sdkCfg config.SDKConfig\n\tif cfg != nil {\n\t\tsdkCfg = cfg.SDKConfig\n\t\tif effectiveProxyURL == \"\" {\n\t\t\teffectiveProxyURL = strings.TrimSpace(cfg.ProxyURL)\n\t\t}\n\t}\n\tsdkCfg.ProxyURL = effectiveProxyURL\n\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 {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/xai.go#L32-L68","documentation":"Error \"xai discovery %s is empty\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/xai.go:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the required xAI discovery endpoint value in the configuration.","Verify the discovery document fields are populated before use."],"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"}