AlistGo/alist · error
not found 302 redirect
Error message
not found 302 redirect
What it means
Thrown by BaiduPhoto.linkAlbum (drivers/baidu_photo/utils.go:360) when the download-request endpoint for an album file does not answer with HTTP 302. The driver expects the server to redirect to the real file URL and reads the Location header to build model.Link; any other status (200 with an error page, 4xx/5xx) means no download link was issued.
Source
Thrown at drivers/baidu_photo/utils.go:360
}
resp, err := d.Request(base.NoRedirectClient, ALBUM_API_URL+"/download", http.MethodHead, func(r *resty.Request) {
r.SetContext(ctx)
r.SetHeaders(headers)
r.SetQueryParams(map[string]string{
"fsid": fmt.Sprint(file.Fsid),
"album_id": file.AlbumID,
"tid": fmt.Sprint(file.Tid),
"uk": fmt.Sprint(file.Uk),
})
}, nil)
if err != nil {
return nil, err
}
if resp.StatusCode() != 302 {
return nil, fmt.Errorf("not found 302 redirect")
}
location := resp.Header().Get("Location")
link := &model.Link{
URL: location,
Header: http.Header{
"User-Agent": []string{headers["User-Agent"]},
"Referer": []string{"https://photo.baidu.com/"},
},
}
return link, nil
}
func (d *BaiduPhoto) linkFile(ctx context.Context, file *File, args model.LinkArgs) (*model.Link, error) {
headers := map[string]string{
"User-Agent": base.UserAgent,
}View on GitHub (pinned to 843d9dc814)
Solutions
- Re-init/refresh the driver credentials (cookies/access_token) and retry Link once
- Re-list the album and confirm the file still exists before linking
- Check errno in the response body of the failed request to distinguish auth vs missing-file
Example fix
// before
if resp.StatusCode() != 302 {
return nil, fmt.Errorf("not found 302 redirect")
}
// after
if resp.StatusCode() != 302 {
if utils.Json.Get(resp.Body(), "errno").ToInt() == -6 {
return nil, errs.NewErr(errs.TokenExpired, "album link: session expired, status %d", resp.StatusCode())
}
return nil, fmt.Errorf("not found 302 redirect, got status %d body %s", resp.StatusCode(), resp.Body())
} Defensive patterns
Strategy: retry
Try / catch
link, err := d.linkAlbum(ctx, file, args)
if err != nil && strings.Contains(err.Error(), "not found 302 redirect") {
if ierr := d.Init(ctx); ierr == nil { // refresh cookies/session
link, err = d.linkAlbum(ctx, file, args)
}
}
if err != nil {
return nil, err
} Prevention
- Re-list the album before linking to confirm the file still exists
- Keep driver sessions warm: re-init on schedule rather than waiting for link failures
- Cap retries at one — a second non-302 usually means the file is gone, not a transient fault
When it happens
Trigger: Calling Link on an AlbumFile whose download request returns non-302: expired or invalid cookies/token for the album owner, the file was removed from the album, or Baidu served an anti-bot/validation page instead of the redirect.
Common situations: Playing album files after the session cookies went stale; fetching links for files deleted since the last list; aggressive polling causing Baidu to drop the redirect.
Related errors
- missing cookie or qrcode account
- oss: chunkNum invalid
- e.Message
- stopped after 10 redirects
- invalid range: failed to overlap
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/9f4d1601b8f624b2.
Report an issue: GitHub.