AlistGo/alist · warning
get size from url %s failed, status code: %d
Error message
get size from url %s failed, status code: %d
What it means
With head_size enabled, the url_tree driver issues a HEAD request to each file URL to learn Content-Length. If the server answers with a status >= 300 (redirect chains not followed to a 2xx, 403 auth wall, 404, 429), getSizeFromUrl reports the URL and status code. The node is still created (size stays 0) because the caller only logs this error.
Source
Thrown at drivers/url_tree/util.go:188
return nil, errs.ObjectNotFound
}
return &model.Object{
Name: node.Name,
Size: node.Size,
Modified: time.Unix(node.Modified, 0),
IsFolder: !node.isFile(),
Path: path,
}, nil
}
func getSizeFromUrl(url string) (int64, error) {
res, err := base.RestyClient.R().SetDoNotParseResponse(true).Head(url)
if err != nil {
return 0, err
}
defer res.RawResponse.Body.Close()
if res.StatusCode() >= 300 {
return 0, fmt.Errorf("get size from url %s failed, status code: %d", url, res.StatusCode())
}
size, err := strconv.ParseInt(res.Header().Get("Content-Length"), 10, 64)
if err != nil {
return 0, err
}
return size, nil
}
func StringifyTree(node *Node) string {
sb := strings.Builder{}
if node.Level == -1 {
for i, child := range node.Children {
sb.WriteString(StringifyTree(child))
if i < len(node.Children)-1 {
sb.WriteString("\n")
}
}
return sb.String()View on GitHub (pinned to 843d9dc814)
Solutions
- Verify the URL with curl -I; fix expiry/signature or use a stable URL.
- Disable head_size and provide explicit sizes in the structure if the origin cannot serve HEAD reliably.
- If the origin rejects HEAD with 405/403 but allows GET, proxy it or precompute sizes; some servers can be configured to allow HEAD.
Example fix
// before: url with expired signature file https://cdn/x.mp4?sig=expired // after: refresh the URL or disable head_size and set size inline file.mp4:1234567: https://cdn/x.mp4
Defensive patterns
Strategy: fallback
Validate before calling
func checkHEADOk(fileURL string) bool {
res, err := base.RestyClient.R().Head(fileURL)
return err == nil && res.StatusCode() < 300
} Try / catch
// in-tree behavior: error is logged, size stays 0 — callers should tolerate size 0
if size, err := getSizeFromUrl(u); err != nil {
log.Warnf("size probe failed (%v); using 0", err)
size = 0
} Prevention
- Verify URLs with curl -I before enabling head_size
- Prefer explicit sizes in the structure for signed/expiring URLs
- Disable head_size for origins that block HEAD or bot-protect paths
When it happens
Trigger: HEAD request to a signed/expired URL (403), a URL behind Cloudflare or bot protection (403/429), a redirect loop, or a typo'd/dead origin (404/5xx) during BuildTree with head_size on.
Common situations: Time-limited signed URLs in the config, origins that reject HEAD (some return 405), or anti-bot layers. Noticeable as files showing 0 size in the mount.
Related errors
- missing cookie or qrcode account
- not get file info
- chunkNum invalid
- oss: chunkNum invalid
- access_token expired: provide a refresh_token together with
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/01bc8ec3f7ee000c.
Report an issue: GitHub.