{"record":{"id":"375d6a26861d0b8c","repo":"AlistGo/alist","slug":"invalid-port","errorCode":null,"errorMessage":"invalid port","messagePattern":"invalid port","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/ftp.go","lineNumber":210,"sourceCode":"\t\tExposedStart  int\n\t\tListenedStart int\n\t\tLength        int\n\t}\n\tgroups := make([]group, len(pasvPortMappers))\n\ttotalLength := 0\n\tconvertToPorts := func(str string) (int, int, error) {\n\t\tstart, end, multi := strings.Cut(str, \"-\")\n\t\tif multi {\n\t\t\tsi, err := strconv.Atoi(start)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, 0, err\n\t\t\t}\n\t\t\tei, err := strconv.Atoi(end)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, 0, err\n\t\t\t}\n\t\t\tif ei < si || ei < 1024 || si < 1024 || ei > 65535 || si > 65535 {\n\t\t\t\treturn 0, 0, errors.New(\"invalid port\")\n\t\t\t}\n\t\t\treturn si, ei - si + 1, nil\n\t\t} else {\n\t\t\tret, err := strconv.Atoi(str)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, 0, err\n\t\t\t} else {\n\t\t\t\treturn ret, 1, nil\n\t\t\t}\n\t\t}\n\t}\n\tfor i, mapper := range pasvPortMappers {\n\t\tvar err error\n\t\texposed, listened, mapped := strings.Cut(mapper, \":\")\n\t\tfor {\n\t\t\tif mapped {\n\t\t\t\tvar es, ls, el, ll int\n\t\t\t\tes, el, err = convertToPorts(exposed)","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/server/ftp.go#L192-L228","documentation":"Returned by the convertToPorts closure that parses the FTP passive-port-range setting. For a range 'start-end' it requires end >= start, both ends within 1024-65535, and both numeric. On failure the caller logs 'failed to convert FTP PASV port mapper ...' at fatal level and the whole mapper function is not installed.","triggerScenarios":"The passive port setting contains a range like '50000-49999' (inverted), '80-443' or '21-1023' (below 1024, reserved for privileged ports), '1-70000' (above 65535), or non-numeric text such as '50000 - 50100' (spaces).","commonSituations":"Copying a docker -p mapping style value with spaces; trying to reuse ports below 1024 without realizing the validation forbids them; typos like '50100-50000'; trailing newline/comma fragments after editing the setting.","solutions":["Use a valid ascending range fully inside 1024-65535, e.g. '50000-50100'","Remove spaces, quotes and stray commas/newlines from the setting value","Restart AList after fixing; check the log for the 'port mapper will be ignored' fatal line to confirm it parsed"],"exampleFix":"// before\npasv: \"50100 - 50000\"\n// after\npasv: \"50000-50100\"","handlingStrategy":"validation","validationCode":"var pasvRange = regexp.MustCompile(`^[1-9][0-9]{3,4}-[1-9][0-9]{3,4}$`)\nfunc validPasvRange(s string) bool {\n    if !pasvRange.MatchString(s) { return false }\n    lo, hi, _ := strings.Cut(s, \"-\")\n    l, h := mustAtoi(lo), mustAtoi(hi)\n    return l >= 1024 && h <= 65535 && h >= l\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the passive port setting in config-management (ansible/helm) templates before deploy","Standardize on one range like 50000-50100 and never edit it by hand in two places","Watch the startup log for 'port mapper will be ignored' — the server logs fatal and drops the mapper"],"tags":["ftp","config","validation","network"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}