{"record":{"id":"5daf7a3244eb52ab","repo":"router-for-me/CLIProxyAPI","slug":"failed-to-create-token-request-w","errorCode":null,"errorMessage":"failed to create token request: %w","messagePattern":"failed to create token request: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/claude/anthropic_auth.go","lineNumber":402,"sourceCode":"\t\tCodeVerifier: pkceCodes.CodeVerifier,\n\t\tState:        state,\n\t}\n\n\t// A state fragment appended to the callback code takes precedence.\n\tif newState != \"\" {\n\t\treqBody.State = newState\n\t}\n\n\tjsonBody, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal request body: %w\", err)\n\t}\n\n\t// log.Debugf(\"Token exchange request: %s\", string(jsonBody))\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", TokenURL, strings.NewReader(string(jsonBody)))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create token request: %w\", err)\n\t}\n\tapplyClaudeOAuthAxiosHeaders(req)\n\n\tresp, err := o.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"token exchange request failed: %w\", err)\n\t}\n\tdefer func() {\n\t\tif errClose := resp.Body.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"failed to close response body: %v\", errClose)\n\t\t}\n\t}()\n\n\tbody, err := readClaudeOAuthResponseBody(resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read token response: %w\", err)\n\t}\n\t// log.Debugf(\"Token response: %s\", string(body))","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/anthropic_auth.go#L384-L420","documentation":"Error \"failed to create token request: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/claude/anthropic_auth.go:402 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 the request construction failure 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"}