{"record":{"id":"4d3de3210e2d4010","repo":"fatedier/frp","slug":"range-number-is-invalid-v","errorCode":null,"errorMessage":"range number is invalid, %v","messagePattern":"range number is invalid, (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/types/types.go","lineNumber":151,"sourceCode":"\treturn strings.Join(strs, \",\")\n}\n\n// the format of str is like \"1000-2000,3000,4000-5000\"\nfunc NewPortsRangeSliceFromString(str string) ([]PortsRange, error) {\n\tstr = strings.TrimSpace(str)\n\tout := []PortsRange{}\n\tnumRanges := strings.SplitSeq(str, \",\")\n\tfor numRangeStr := range numRanges {\n\t\t// 1000-2000 or 2001\n\t\tnumArray := strings.Split(numRangeStr, \"-\")\n\t\t// length: only 1 or 2 is correct\n\t\trangeType := len(numArray)\n\t\tswitch rangeType {\n\t\tcase 1:\n\t\t\t// single number\n\t\t\tsingleNum, err := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"range number is invalid, %v\", err)\n\t\t\t}\n\t\t\tout = append(out, PortsRange{Single: int(singleNum)})\n\t\tcase 2:\n\t\t\t// range numbers\n\t\t\tminNum, err := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"range number is invalid, %v\", err)\n\t\t\t}\n\t\t\tmaxNum, err := strconv.ParseInt(strings.TrimSpace(numArray[1]), 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"range number is invalid, %v\", err)\n\t\t\t}\n\t\t\tif maxNum < minNum {\n\t\t\t\treturn nil, fmt.Errorf(\"range number is invalid\")\n\t\t\t}\n\t\t\tout = append(out, PortsRange{Start: int(minNum), End: int(maxNum)})\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"range number is invalid\")","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/pkg/config/types/types.go#L133-L169","documentation":"Thrown while unmarshalling a PortsRange value (pkg/config/types/types.go) when a comma-separated port list contains a single token that is not a valid 64-bit integer. The parser splits the string on commas, then on '-'; a token with no dash is treated as a single port and must parse with strconv.ParseInt. Any syntax or overflow failure (wrapped with %v) produces this error during PortsRange.UnmarshalJSON.","triggerScenarios":"PortsRange JSON unmarshal on input like \"808 0\" (space), \"0x50\" (hex not supported), \"http\" (non-numeric), \"99999999999999999999\" (int64 overflow), or a trailing comma producing an empty token.","commonSituations":"Typos in remotePort/localPort strings in frpc TOML/JSON; pasting IANA service names (\"http\", \"ssh\") where frp expects numeric ports; a trailing comma in a JSON port list; values copied from a spreadsheet with non-breaking spaces or thousand separators.","solutions":["Correct the offending token to a plain decimal integer within int64 range (and practical port range 0-65535), e.g. \"8080\".","Remove trailing/leading commas and stray whitespace in the comma-separated port list.","Replace service names with their numeric port equivalents (http -> 80, ssh -> 22)."],"exampleFix":"# before\nremotePort = \"80 80\"\n\n# after\nremotePort = 8080","handlingStrategy":"validation","validationCode":"// Validate every comma-separated token is a plain int64 before unmarshalling.\nfunc validPortsString(s string) error {\n\tfor _, tok := range strings.Split(s, \",\") {\n\t\tif _, err := strconv.ParseInt(strings.TrimSpace(tok), 10, 64); err != nil {\n\t\t\treturn fmt.Errorf(\"bad port token %q: %w\", tok, err)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isPlainPort(s string) bool {\n\t_, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64)\n\treturn err == nil\n}","tryCatchPattern":null,"preventionTips":["Use plain decimal integers only; no hex, names, or separators.","Run frpc verify (or your loader) in CI to catch port string typos before deploy.","Watch for trailing commas and stray spaces in port lists."],"tags":["go","frp","config","json","port-range","parse-error"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}