{"record":{"id":"131322c18babc3ef","repo":"router-for-me/CLIProxyAPI","slug":"kimi-failed-to-create-refresh-request-w","errorCode":null,"errorMessage":"kimi: failed to create refresh request: %w","messagePattern":"kimi: failed to create refresh request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/kimi/kimi.go","lineNumber":377,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttokenData, ok := result.(*KimiTokenData)\n\tif !ok || tokenData == nil {\n\t\treturn nil, fmt.Errorf(\"kimi: refresh token failed: invalid single-flight result\")\n\t}\n\treturn tokenData, nil\n}\n\nfunc (c *DeviceFlowClient) refreshTokenSingleFlight(ctx context.Context, refreshToken string) (*KimiTokenData, error) {\n\tdata := url.Values{}\n\tdata.Set(\"client_id\", kimiClientID)\n\tdata.Set(\"grant_type\", \"refresh_token\")\n\tdata.Set(\"refresh_token\", refreshToken)\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, kimiTokenURL, strings.NewReader(data.Encode()))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"kimi: failed to create refresh request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\treq.Header.Set(\"Accept\", \"application/json\")\n\tfor k, v := range c.commonHeaders() {\n\t\treq.Header.Set(k, v)\n\t}\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"kimi: refresh request failed: %w\", err)\n\t}\n\tdefer func() {\n\t\tif errClose := resp.Body.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"kimi refresh token: close body error: %v\", errClose)\n\t\t}\n\t}()\n\n\tbodyBytes, err := io.ReadAll(resp.Body)","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/kimi/kimi.go#L359-L395","documentation":"http.NewRequestWithContext failed while building the refresh-token POST to https://auth.kimi.com/api/oauth/token. As with error 225, all inputs (method, constant URL, encoded form body) are fixed, so this is unreachable in a stock build and would only occur in modified code with an invalid URL.","triggerScenarios":"Forked code that changes kimiTokenURL to an invalid URL string; effectively zero occurrence in the shipped binary.","commonSituations":"Custom patches introducing a typo in the token URL constant.","solutions":["If running a fork, verify kimiTokenURL parses as an absolute URL","Otherwise report as a bug — the stock binary cannot produce this error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if u, err := url.Parse(kimiTokenURL); err != nil || !u.IsAbs() {\n    return nil, fmt.Errorf(\"kimi: misconfigured token URL %q\", kimiTokenURL)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only reachable in modified builds: unit-test URL constants","Report stock-build occurrences as bugs"],"tags":["kimi","oauth","refresh-token","http","unreachable"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}