{"record":{"id":"a0d8af550e349466","repo":"router-for-me/CLIProxyAPI","slug":"parse-claude-oauth-profile-response-w","errorCode":null,"errorMessage":"parse Claude OAuth profile response: %w","messagePattern":"parse Claude OAuth profile response: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/claude/anthropic_auth.go","lineNumber":268,"sourceCode":"\tbody, errRead := readClaudeOAuthResponseBody(resp)\n\tif errRead != nil {\n\t\treturn nil, fmt.Errorf(\"read Claude OAuth %s response: %w\", label, errRead)\n\t}\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {\n\t\treturn nil, fmt.Errorf(\"fetch Claude OAuth %s failed with status %d\", label, resp.StatusCode)\n\t}\n\treturn body, nil\n}\n\n// FetchOAuthProfile retrieves the account identity associated with an OAuth access token.\nfunc (o *ClaudeAuth) FetchOAuthProfile(ctx context.Context, accessToken string) (*OAuthProfile, error) {\n\tbody, errFetch := o.fetchOAuthControlPlaneJSON(ctx, ProfileURL, accessToken, \"profile\")\n\tif errFetch != nil {\n\t\treturn nil, errFetch\n\t}\n\tvar profile OAuthProfile\n\tif errUnmarshal := json.Unmarshal(body, &profile); errUnmarshal != nil {\n\t\treturn nil, fmt.Errorf(\"parse Claude OAuth profile response: %w\", errUnmarshal)\n\t}\n\tif strings.TrimSpace(profile.Account.UUID) == \"\" {\n\t\treturn nil, fmt.Errorf(\"fetch Claude OAuth profile: response account UUID is empty\")\n\t}\n\treturn &profile, nil\n}\n\n// FetchOAuthRoles performs the claude_cli roles lookup the native client issues\n// alongside the profile query after a token exchange. Only the request shape is\n// covered by captured evidence, so the payload stays opaque and is returned raw\n// instead of being decoded into a guessed structure.\nfunc (o *ClaudeAuth) FetchOAuthRoles(ctx context.Context, accessToken string) (json.RawMessage, error) {\n\tbody, errFetch := o.fetchOAuthControlPlaneJSON(ctx, RolesURL, accessToken, \"claude_cli roles\")\n\tif errFetch != nil {\n\t\treturn nil, errFetch\n\t}\n\tif !json.Valid(body) {\n\t\treturn nil, fmt.Errorf(\"parse Claude OAuth claude_cli roles response: body is not valid JSON\")","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/anthropic_auth.go#L250-L286","documentation":"Error \"parse Claude OAuth profile response: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/claude/anthropic_auth.go:268 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the OAuth profile endpoint returned valid JSON matching the expected schema.","Check the wrapped error for the JSON decode failure and inspect the raw response body."],"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"}