XTLS/Xray-core · error
invalid size
Error message
invalid size
What it means
Sentinel error returned by ByteSize parsing when the numeric part of the size string cannot be parsed as a positive float (strconv error or value <= 0). The input string's byte-count component is at fault, not the unit (which has its own errInvalidUnit sentinel).
Solutions
- Provide a positive numeric value, e.g. '1024', '1.5MB'
- Check for stray characters in the number
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at common/units/bytesize.go:11 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/95a4b89fa7fa823a.
Report an issue: GitHub.
Appendix: source
Thrown at common/units/bytesize.go:11
package units
import (
"errors"
"strconv"
"strings"
"unicode"
)
var (
errInvalidSize = errors.New("invalid size")
errInvalidUnit = errors.New("invalid or unsupported unit")
)
// ByteSize is the size of bytes
type ByteSize uint64
const (
_ = iota
// KB = 1KB
KB ByteSize = 1 << (10 * iota)
// MB = 1MB
MB
// GB = 1GB
GB
// TB = 1TB
TB
// PB = 1PB
PBView on GitHub (pinned to 7d214f8b09)