AlistGo/alist · error

invalid line: %s, because file name can't be empty

Error message

invalid line: %s, because file name can't be empty

What it means

After stripping the trailing ':' from the metadata segment of a url_tree file line, the remaining string is empty — meaning the line looks like ':https://...' with no file name at all. A file node requires a name, so parseFileLine rejects it.

Source

Thrown at drivers/url_tree/util.go:119

		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)
		}
		infoParts := strings.Split(info, ":")
		node.Name = infoParts[0]
		if len(infoParts) > 1 {
			size, err := strconv.ParseInt(infoParts[1], 10, 64)
			if err != nil {
				return nil, fmt.Errorf("invalid line: %s, because file size must be an integer", line)
			}
			node.Size = size
			haveSize = true
			if len(infoParts) > 2 {
				modified, err := strconv.ParseInt(infoParts[2], 10, 64)
				if err != nil {
					return nil, fmt.Errorf("invalid line: %s, because file modified must be an unix timestamp", line)
				}
				node.Modified = modified
			}
		}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Provide a real file name before the first ':' (name:URL).
  2. If you want the URL's last path segment as the name, drop the entire metadata prefix and use the bare URL line.
  3. Check for accidental leading ':' after copy-paste edits.

Example fix

// before
: https://x/files/a.mp4

// after
https://x/files/a.mp4   // name defaults to 'a.mp4'
Defensive patterns

Strategy: validation

Validate before calling

func validateNonEmptyName(line string) error {
    idx := strings.Index(line, "http")
    if idx <= 0 { return nil }
    info := strings.TrimSuffix(line[:idx], ":")
    if strings.TrimSpace(info) == "" {
        return fmt.Errorf("file name missing before URL")
    }
    return nil
}

Try / catch

if err != nil && strings.Contains(err.Error(), "file name can't be empty") { /* add a name or drop the leading ':' */ }

Prevention

When it happens

Trigger: Lines where the only pre-URL content is ':' (e.g. ':1024:https://x' is fine because name is empty but parts exist — actually the check fires when info after removing ':' is empty, i.e. exactly ':https://...' or '::https://...' trimmed cases yielding empty info string).

Common situations: Deleting the file name while keeping separators, or attempting to use ':' alone to denote 'use URL basename' (the driver does not support that; omit the whole prefix instead).

Related errors


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