AlistGo/alist · error

invalid line: %s, because url is required for file

Error message

invalid line: %s, because url is required for file

What it means

In url_tree's line format ([FileName:][FileSize:][Modified:]Url), a non-folder line must contain an http:// or https:// URL. parseFileLine rejects lines (after folder ':' suffix detection) that contain neither scheme, because a file node without a URL cannot serve a download link.

Source

Thrown at drivers/url_tree/util.go:101

			}
			node.Level = level
			// add the node to the top of the stack
			stack[len(stack)-1].Children = append(stack[len(stack)-1].Children, node)
		}
	}
	return root, nil
}

func isFolder(line string) bool {
	return strings.HasSuffix(line, ":")
}

// line definition:
// [FileName:][FileSize:][Modified:]Url
func parseFileLine(line string, headSize bool) (*Node, error) {
	// if there is no url, it is an error
	if !strings.Contains(line, "http://") && !strings.Contains(line, "https://") {
		return nil, fmt.Errorf("invalid line: %s, because url is required for file", line)
	}
	index := strings.Index(line, "http://")
	if index == -1 {
		index = strings.Index(line, "https://")
	}
	url := line[index:]
	info := line[:index]
	node := &Node{
		Url: url,
	}
	haveSize := false
	if index > 0 {
		if !strings.HasSuffix(info, ":") {
			return nil, fmt.Errorf("invalid line: %s, because file info must end with ':'", line)
		}
		info = info[:len(info)-1]
		if info == "" {
			return nil, fmt.Errorf("invalid line: %s, because file name can't be empty", line)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Ensure every file line embeds a full http:// or https:// URL at its end.
  2. For non-HTTP sources, host them behind an HTTP reverse proxy and use that URL.
  3. Remove accidental text/comment lines from url_structure (there is no comment syntax).

Example fix

// before
video.mp4:1024: ftp://srv/video.mp4

// after
video.mp4:1024: https://srv/video.mp4
Defensive patterns

Strategy: validation

Validate before calling

func lineHasURL(line string) bool {
    return strings.Contains(line, "http://") || strings.Contains(line, "https://")
}

Try / catch

if err != nil && strings.Contains(err.Error(), "url is required for file") {
    // point user at the echoed line; fix scheme or remove stray text
}

Prevention

When it happens

Trigger: A tree line that is not a folder (no trailing ':') and lacks http:// and https:// anywhere — typos like 'htp://', ftp:// links, or stray text lines inside the structure.

Common situations: Using ftp:// or magnet: URLs (unsupported), a stray comment or blank-with-text line, or URL split across lines by wrapping. Fails during Init/BuildTree.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/7a654090b9e3460d. Report an issue: GitHub.