{"record":{"id":"78454af916f618ff","repo":"AlistGo/alist","slug":"failed-to-decode-rename-response-w","errorCode":null,"errorMessage":"failed to decode rename response: %w","messagePattern":"failed to decode rename response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/proton_drive/util.go","lineNumber":662,"sourceCode":"\thttpReq.Header.Set(\"X-Pm-Appversion\", d.webDriveAV)\n\thttpReq.Header.Set(\"X-Pm-Drive-Sdk-Version\", d.sdkVersion)\n\thttpReq.Header.Set(\"X-Pm-Uid\", d.credentials.UID)\n\thttpReq.Header.Set(\"Authorization\", \"Bearer \"+d.credentials.AccessToken)\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(httpReq)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to execute rename request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"rename failed with status %d\", resp.StatusCode)\n\t}\n\n\tvar renameResp RenameResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&renameResp); err != nil {\n\t\treturn fmt.Errorf(\"failed to decode rename response: %w\", err)\n\t}\n\n\tif renameResp.Code != 1000 {\n\t\treturn fmt.Errorf(\"rename failed with code %d\", renameResp.Code)\n\t}\n\n\treturn nil\n}\n\nfunc (d *ProtonDrive) executeMoveAPI(ctx context.Context, linkID string, req MoveRequest) error {\n\t//fmt.Printf(\"DEBUG Move Request - Name: %s\\n\", req.Name)\n\t//fmt.Printf(\"DEBUG Move Request - Hash: %s\\n\", req.Hash)\n\t//fmt.Printf(\"DEBUG Move Request - OriginalHash: %s\\n\", req.OriginalHash)\n\t//fmt.Printf(\"DEBUG Move Request - ParentLinkID: %s\\n\", req.ParentLinkID)\n\n\t//fmt.Printf(\"DEBUG Move Request - Name length: %d\\n\", len(req.Name))\n\t//fmt.Printf(\"DEBUG Move Request - NameSignatureEmail: %s\\n\", req.NameSignatureEmail)\n\t//fmt.Printf(\"DEBUG Move Request - ContentHash: %v\\n\", req.ContentHash)","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/proton_drive/util.go#L644-L680","documentation":"The rename response body (on a 200) could not be JSON-decoded into RenameResponse. Proton normally returns {Code, Response...} JSON, so a decode failure means the body was not Proton JSON — typically an HTML error page from an intercepting proxy, Cloudflare, or a captive portal, or an empty/truncated body.","triggerScenarios":"TLS-intercepting middlebox answering 200 with HTML; connection closed early truncating the JSON; Content-Encoding mismatch; unexpected empty body on some gateway errors.","commonSituations":"Corporate proxies and antivirus TLS inspection; flaky mobile links where the body is cut off; CDN edge nodes serving a soft-block page that still returns 200.","solutions":["Capture the raw body (tee it) before decoding to see what was actually returned","Bypass TLS-inspecting proxies for the Proton API host","Retry on truncation — it is usually transient","If HTML is consistently returned, the endpoint is being blocked; fix the network path"],"exampleFix":"// before\nif err := json.NewDecoder(resp.Body).Decode(&renameResp); err != nil {\n// after\nbody, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<20))\nif err := json.Unmarshal(body, &renameResp); err != nil {\n\treturn fmt.Errorf(\"failed to decode rename response (%q): %w\", truncate(body, 200), err)\n}","handlingStrategy":"try-catch","validationCode":"// sanity check before decode is not possible remotely; guard by checking content type\nif ct := resp.Header.Get(\"Content-Type\"); ct != \"\" && !strings.Contains(ct, \"json\") {\n    return fmt.Errorf(\"unexpected content-type %s from rename endpoint\", ct)\n}","typeGuard":null,"tryCatchPattern":"if err := d.Rename(ctx, src, newName); err != nil {\n    var syn *json.SyntaxError\n    if errors.As(err, &syn) {\n        // non-JSON body: proxy/middlebox interference — check network path, then retry\n    }\n}","preventionTips":["Bypass TLS-inspecting proxies for the Proton API host","Log raw bodies on decode failures in your fork of the driver"],"tags":["proton-drive","json","network","proxy"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}