{"record":{"id":"42a5ffb0bd779f63","repo":"router-for-me/CLIProxyAPI","slug":"xai-discovery-s-is-invalid-w","errorCode":null,"errorMessage":"xai discovery %s is invalid: %w","messagePattern":"xai discovery (.+?) is invalid: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/xai.go","lineNumber":54,"sourceCode":"\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 {\n\t\tctx = context.Background()\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, DiscoveryURL, nil)\n\tif err != nil {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/xai.go#L36-L72","documentation":"Error \"xai discovery %s is invalid: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/xai.go:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the malformed discovery endpoint URL reported by the wrapped parse error.","Ensure the value is a well-formed absolute URL."],"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"}