XTLS/Xray-core · error

customTable must contain exactly 2 x, 2 p and 4 v

Error message

customTable must contain exactly 2 x, 2 p and 4 v

What it means

Thrown by normalizeCustomTable when the pattern has the right length and alphabet but the wrong composition: it must contain exactly 2 x, 2 p, and 4 v. This composition is a hard requirement of the sudoku encoding (2 mask bits, 2 position bits, 4 value bits per byte), not a style preference.

Source

Thrown at transport/internet/finalmask/sudoku/table.go:199

	if len(cleaned) != 8 {
		return "", fmt.Errorf("customTable must be 8 chars, got %d", len(cleaned))
	}

	var xCount, pCount, vCount int
	for _, ch := range cleaned {
		switch ch {
		case 'x':
			xCount++
		case 'p':
			pCount++
		case 'v':
			vCount++
		default:
			return "", fmt.Errorf("customTable has invalid char %q", ch)
		}
	}
	if xCount != 2 || pCount != 2 || vCount != 4 {
		return "", fmt.Errorf("customTable must contain exactly 2 x, 2 p and 4 v")
	}
	return cleaned, nil
}

func resolveLayout(mode, customTable string) (*byteLayout, error) {
	if mode == "prefer_ascii" {
		return asciiLayout(), nil
	}

	if customTable != "" {
		return customLayout(customTable)
	}
	return entropyLayout(), nil
}

func asciiLayout() *byteLayout {
	padding := make([]byte, 0, 32)
	for i := 0; i < 32; i++ {

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Ensure the pattern contains exactly two x, two p, and four v characters in any order.
  2. Start from the canonical "xxppvvvv" and permute positions only.
  3. Leave customTable empty to use the default layout if the exact arrangement is not important.

Example fix

// before
"customTable": "xxxppvvv"
// after
"customTable": "xxppvvvv"
Defensive patterns

Strategy: validation

Validate before calling

func validCustomTable(pattern string) bool {
	p := strings.ReplaceAll(strings.ToLower(strings.TrimSpace(pattern)), " ", "")
	if len(p) != 8 {
		return false
	}
	var x, q, v int
	for _, ch := range p {
		switch ch {
		case 'x': x++
		case 'p': q++
		case 'v': v++
		default: return false
		}
	}
	return x == 2 && q == 2 && v == 4
}

if !validCustomTable(cfg.CustomTable) {
	return errors.New("reject config: customTable must have 2 x, 2 p, 4 v")
}

Prevention

When it happens

Trigger: Patterns like "xxxppvvv" (3 x, 2 p, 3 v), "xxpppvvv" (2 x, 3 p, 3 v), or "xxppvvvx"-style permutations that break the 2/2/4 count. Any arrangement of the letters is allowed as long as the counts are exactly 2, 2, and 4.

Common situations: Rearranging a working pattern to tune traffic shape and accidentally swapping an x for a v; assuming any 8-char x/p/v string is valid; following an outdated example with a different composition.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/53cb2cfd2739a834. Report an issue: GitHub.