{"record":{"id":"54e656fa2db8abb3","repo":"router-for-me/CLIProxyAPI","slug":"xai-token-request-create-request-w","errorCode":null,"errorMessage":"xai token request: create request: %w","messagePattern":"xai token request: create request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/xai.go","lineNumber":376,"sourceCode":"\treturn tokenData, nil\n}\n\nfunc (a *XAIAuth) refreshTokensSingleFlight(ctx context.Context, refreshToken, tokenEndpoint string) (*TokenData, error) {\n\tform := url.Values{\n\t\t\"grant_type\":    {\"refresh_token\"},\n\t\t\"client_id\":     {ClientID},\n\t\t\"refresh_token\": {refreshToken},\n\t}\n\treturn a.postTokenForm(ctx, tokenEndpoint, form)\n}\n\nfunc (a *XAIAuth) postTokenForm(ctx context.Context, tokenEndpoint string, form url.Values) (*TokenData, error) {\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, strings.TrimSpace(tokenEndpoint), strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"xai token request: create request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\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 token request failed: %w\", err)\n\t}\n\tdefer func() {\n\t\tif errClose := resp.Body.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"xai token request: 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 token response: read body: %w\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"xai token request failed with status %d: %s\", resp.StatusCode, strings.TrimSpace(string(body)))","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/xai.go#L358-L394","documentation":"Error \"xai token request: create request: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/xai.go:376 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the token endpoint 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"}