XTLS/Xray-core · error
invalid range string: {}
Error message
invalid range string: {} What it means
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.
Source
Thrown at infra/conf/common.go:376
if str == "" {
return 0, 0, nil
}
// for range value, like "114-514"
var pair []string
// Process sth like "-114-514" "-1919--810"
if strings.HasPrefix(str, "-") {
pair = splitFromSecondDash(str)
} else {
pair = strings.SplitN(str, "-", 2)
}
if len(pair) == 2 {
left, err := strconv.Atoi(pair[0])
right, err2 := strconv.Atoi(pair[1])
if err == nil && err2 == nil {
return left, right, nil
}
}
return 0, 0, errors.New("invalid range string: ", str)
}
View on GitHub (pinned to 7d214f8b09)
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)
Example fix
// before "length": "100 – 200" // en-dash / spaces // after "length": "100-200"
Defensive patterns
Strategy: validation
Validate before calling
var rangeRE = regexp.MustCompile(`^-?\d+-\d+$|^-?\d+-\(-\d+\)?$`)
func validRangeString(s string) bool {
return rangeRE.MatchString(strings.TrimSpace(s))
} Try / catch
if _, _, err := conf.ParseRangeString(str); err != nil {
return fmt.Errorf("range %q must look like \"1-2\" or \"-1919--810\"", str)
} Prevention
- Use ASCII hyphens only (no en/em dashes from docs copy-paste)
- Exactly one separating hyphen, plus signs only for negative numbers
When it happens
Trigger: "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.
Common situations: 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.
Related errors
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/fec0dd8e8d9b67bf.
Report an issue: GitHub.