{"record":{"id":"fec0dd8e8d9b67bf","repo":"XTLS/Xray-core","slug":"invalid-range-string","errorCode":null,"errorMessage":"invalid range string: {}","messagePattern":"invalid range string: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/common.go","lineNumber":376,"sourceCode":"\tif str == \"\" {\n\t\treturn 0, 0, nil\n\t}\n\t// for range value, like \"114-514\"\n\tvar pair []string\n\t// Process sth like \"-114-514\" \"-1919--810\"\n\tif strings.HasPrefix(str, \"-\") {\n\t\tpair = splitFromSecondDash(str)\n\t} else {\n\t\tpair = strings.SplitN(str, \"-\", 2)\n\t}\n\tif len(pair) == 2 {\n\t\tleft, err := strconv.Atoi(pair[0])\n\t\tright, err2 := strconv.Atoi(pair[1])\n\t\tif err == nil && err2 == nil {\n\t\t\treturn left, right, nil\n\t\t}\n\t}\n\treturn 0, 0, errors.New(\"invalid range string: \", str)\n}\n","sourceCodeStart":358,"sourceCodeEnd":378,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/common.go#L358-L378","documentation":"Returned by ParseRangeString in infra/conf/common.go when splitting 'str' on dashes (with special handling for leading negatives like '-114-514') does not yield two integer-parseable halves. strconv.Atoi must succeed on both parts; otherwise this error with the original string is returned.","triggerScenarios":"\"1-\" , \"-abc\", \"1-2-3\" (right half '2-3' fails Atoi), \"100--\" or empty string. Negative ranges like \"-1919--810\" are supported; malformed negatives like \"--810\" are not.","commonSituations":"Hand-editing fragmentation or buffer-size ranges; copy-pasting from documentation that uses en-dashes instead of ASCII hyphens; leaving a placeholder like 'MIN-MAX' in the config.","solutions":["Write ranges as two integers joined by one ASCII hyphen: \"100-200\"","For negative bounds put the sign on the number: \"-1919--810\"","Ensure no extra hyphens or spaces: exactly one separating hyphen (plus signs for negatives)"],"exampleFix":"// before\n\"length\": \"100 – 200\"   // en-dash / spaces\n\n// after\n\"length\": \"100-200\"","handlingStrategy":"validation","validationCode":"var rangeRE = regexp.MustCompile(`^-?\\d+-\\d+$|^-?\\d+-\\(-\\d+\\)?$`)\n\nfunc validRangeString(s string) bool {\n    return rangeRE.MatchString(strings.TrimSpace(s))\n}","typeGuard":null,"tryCatchPattern":"if _, _, err := conf.ParseRangeString(str); err != nil {\n    return fmt.Errorf(\"range %q must look like \\\"1-2\\\" or \\\"-1919--810\\\"\", str)\n}","preventionTips":["Use ASCII hyphens only (no en/em dashes from docs copy-paste)","Exactly one separating hyphen, plus signs only for negative numbers"],"tags":["config","validation","parsing","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}