{"record":{"id":"bd23214f7b808da0","repo":"AlistGo/alist","slug":"redirect-failed-status-d-msg-s","errorCode":null,"errorMessage":"redirect failed, status: %d, msg: %s","messagePattern":"redirect failed, status: (.+?), msg: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/ilanzou/driver.go","lineNumber":169,"sourceCode":"\t// get the url after redirect\n\treq := base.NoRedirectClient.R()\n\n\treq.SetHeaders(map[string]string{\n\t\t\"Referer\":    d.conf.site + \"/\",\n\t\t\"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0\",\n\t})\n\tif d.Addition.Ip != \"\" {\n\t\treq.SetHeader(\"X-Forwarded-For\", d.Addition.Ip)\n\t}\n\n\tres, err := req.Get(realURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif res.StatusCode() == 302 {\n\t\trealURL = res.Header().Get(\"location\")\n\t} else {\n\t\treturn nil, fmt.Errorf(\"redirect failed, status: %d, msg: %s\", res.StatusCode(), utils.Json.Get(res.Body(), \"msg\").ToString())\n\t}\n\tlink := model.Link{URL: realURL}\n\treturn &link, nil\n}\n\nfunc (d *ILanZou) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {\n\tres, err := d.proved(\"/file/folder/save\", http.MethodPost, func(req *resty.Request) {\n\t\treq.SetBody(base.Json{\n\t\t\t\"folderDesc\": \"\",\n\t\t\t\"folderId\":   parentDir.GetID(),\n\t\t\t\"folderName\": dirName,\n\t\t})\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &model.Object{\n\t\tID: utils.Json.Get(res, \"list\", 0, \"id\").ToString(),","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/ilanzou/driver.go#L151-L187","documentation":"Thrown by ILanZou's link resolution when the download-URL request returns anything other than a 302 redirect. The driver relies on the server answering with a Location header pointing at the real file host; any other status (200 HTML error page, 403, 429) is a failure. The server's JSON msg is extracted and included.","triggerScenarios":"The file was deleted or set private between listing and link fetch; anti-leech token/cookie expired; IP ban (the X-Forwarded-For spoof via Addition.Ip no longer accepted); rate limiting on the redirect endpoint.","commonSituations":"Expired share links; too-frequent programmatic downloads from one IP; wrong Addition.Ip configuration; ilanzou changing their redirect flow so the endpoint now returns 200 with an error body instead of 302.","solutions":["Read the embedded msg — it distinguishes 'file not exist' from rate-limit/auth errors.","Re-list the directory to confirm the file still exists; deleted files are a top cause.","Set/rotate Addition.Ip (X-Forwarded-For) to a residential-looking IP if the server blocks datacenter IPs.","Back off and retry later for 429-style rate limiting; add delay between link resolutions."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"link, err := d.Link(ctx, obj, args)\nif err != nil && strings.Contains(err.Error(), \"redirect failed\") {\n    if !fileStillListed(ctx, parentPath, obj.GetName()) { return errors.New(\"file deleted\") }\n    time.Sleep(2 * time.Second)\n    link, err = d.Link(ctx, obj, args)\n}\nif err != nil { return err }","preventionTips":["Verify the file still exists before resolving links","Throttle link resolution frequency","Keep Addition.Ip (X-Forwarded-For) configured to a stable value"],"tags":["ilanzou","redirect","anti-leech","rate-limit"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}