{"record":{"id":"c0e20484ebe8af80","repo":"chenhg5/cc-connect","slug":"decode-response-w","errorCode":null,"errorMessage":"decode response: %w","messagePattern":"decode response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/feishu.go","lineNumber":523,"sourceCode":"\t\treturn false, err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{Timeout: 10 * time.Second}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer resp.Body.Close()\n\n\tdata, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tvar parsed tenantTokenResponse\n\tif err := json.Unmarshal(data, &parsed); err != nil {\n\t\treturn false, fmt.Errorf(\"decode response: %w\", err)\n\t}\n\tif parsed.Code == 0 && parsed.TenantAccessToken != \"\" {\n\t\treturn true, nil\n\t}\n\tif parsed.Msg != \"\" {\n\t\treturn false, fmt.Errorf(\"code=%d msg=%s\", parsed.Code, parsed.Msg)\n\t}\n\treturn false, nil\n}\n\nfunc runRegistrationFlow(opts registrationFlowOptions) (*registrationFlowResult, error) {\n\tif opts.TimeoutSeconds <= 0 {\n\t\topts.TimeoutSeconds = 600\n\t}\n\tclient := &registrationClient{\n\t\tbaseURL: accountsFeishuBaseURL,\n\t\thttp:    &http.Client{Timeout: 15 * time.Second},\n\t\tdebug:   opts.Debug,","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/feishu.go#L505-L541","documentation":"validateAppCredentialsAgainstBase issues a POST to the tenant_access_token endpoint and unmarshals the JSON body into tenantTokenResponse. This error wraps any json.Unmarshal failure, meaning the remote answered but not with the expected JSON shape.","triggerScenarios":"The base URL points at a non-Feishu service (proxy/captive portal returning HTML), the endpoint returns an HTML error page, or a malformed/empty JSON body arrives despite HTTP success.","commonSituations":"Corporate proxies intercepting requests; wrong base URL override; network appliances returning login pages; Feishu returning an unexpected content type during incidents.","solutions":["Verify the base URL is the real Feishu/Lark auth endpoint (open.feishu.cn / open.larksuite.com).","Disable or bypass intercepting proxies/VPNs for the request.","Re-run later if Feishu is having an incident; retry may yield a well-formed response.","Inspect the raw response with --debug to see what body was actually received."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"resp, err := http.Post(url, \"application/json\", body); if err == nil { var probe map[string]any; if jerr := json.NewDecoder(resp.Body).Decode(&probe); jerr != nil { return fmt.Errorf(\"endpoint not returning JSON: %w\", jerr) } }","typeGuard":null,"tryCatchPattern":"if _, err := validateAppCredentials(...); err != nil && strings.Contains(err.Error(), \"decode response:\") { log.Printf(\"non-JSON response from auth endpoint: %v; check proxy/base URL\", err) }","preventionTips":["Bypass corporate proxies/VPNs or allowlist the Feishu/Lark auth host.","Use only official base URLs (open.feishu.cn, open.larksuite.com).","Retry during provider incidents; the shape failure is usually transient or environmental."],"tags":["feishu","json","network","validation"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}