{"record":{"id":"7a654090b9e3460d","repo":"AlistGo/alist","slug":"invalid-line-s-because-url-is-required-for-file-7a6540","errorCode":null,"errorMessage":"invalid line: %s, because url is required for file","messagePattern":"invalid line: (.+?), because url is required for file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/url_tree/util.go","lineNumber":101,"sourceCode":"\t\t\t}\n\t\t\tnode.Level = level\n\t\t\t// add the node to the top of the stack\n\t\t\tstack[len(stack)-1].Children = append(stack[len(stack)-1].Children, node)\n\t\t}\n\t}\n\treturn root, nil\n}\n\nfunc isFolder(line string) bool {\n\treturn strings.HasSuffix(line, \":\")\n}\n\n// line definition:\n// [FileName:][FileSize:][Modified:]Url\nfunc parseFileLine(line string, headSize bool) (*Node, error) {\n\t// if there is no url, it is an error\n\tif !strings.Contains(line, \"http://\") && !strings.Contains(line, \"https://\") {\n\t\treturn nil, fmt.Errorf(\"invalid line: %s, because url is required for file\", line)\n\t}\n\tindex := strings.Index(line, \"http://\")\n\tif index == -1 {\n\t\tindex = strings.Index(line, \"https://\")\n\t}\n\turl := line[index:]\n\tinfo := line[:index]\n\tnode := &Node{\n\t\tUrl: url,\n\t}\n\thaveSize := false\n\tif index > 0 {\n\t\tif !strings.HasSuffix(info, \":\") {\n\t\t\treturn nil, fmt.Errorf(\"invalid line: %s, because file info must end with ':'\", line)\n\t\t}\n\t\tinfo = info[:len(info)-1]\n\t\tif info == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid line: %s, because file name can't be empty\", line)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/url_tree/util.go#L83-L119","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure every file line embeds a full http:// or https:// URL at its end.","For non-HTTP sources, host them behind an HTTP reverse proxy and use that URL.","Remove accidental text/comment lines from url_structure (there is no comment syntax)."],"exampleFix":"// before\nvideo.mp4:1024: ftp://srv/video.mp4\n\n// after\nvideo.mp4:1024: https://srv/video.mp4","handlingStrategy":"validation","validationCode":"func lineHasURL(line string) bool {\n    return strings.Contains(line, \"http://\") || strings.Contains(line, \"https://\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"url is required for file\") {\n    // point user at the echoed line; fix scheme or remove stray text\n}","preventionTips":["Only http/https URLs are supported — proxy other protocols first","Keep each file entry on one line","No comment syntax exists in url_structure; delete stray lines"],"tags":["url-tree","url","config","validation"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}