XTLS/Xray-core · error

customTable has invalid char %q

Error message

customTable has invalid char %q

What it means

Thrown by normalizeCustomTable when the 8-character pattern contains a character other than x, p, or v. Each slot in the custom byte layout must be one of these three classes (x = fixed mask bits, p = position bits, v = value bits), so any other rune is invalid.

Source

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

func normalizeCustomTable(pattern string) (string, error) {
	cleaned := strings.ToLower(strings.TrimSpace(pattern))
	cleaned = strings.ReplaceAll(cleaned, " ", "")
	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
}

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Rewrite the pattern using only the letters x, p, and v.
  2. Replace any separator characters with plain spaces or remove them entirely (only spaces are stripped).
  3. Double-check against the 2/2/4 composition rule (2 x, 2 p, 4 v) once the characters are fixed.

Example fix

// before
"customTable": "xx-pp-vvvv"
// after
"customTable": "xxppvvvv"
Defensive patterns

Strategy: validation

Validate before calling

for _, ch := range strings.ReplaceAll(strings.ToLower(strings.TrimSpace(cfg.CustomTable)), " ", "") {
	if ch != 'x' && ch != 'p' && ch != 'v' {
		return fmt.Errorf("customTable has invalid char %q", ch)
	}
}

Prevention

When it happens

Trigger: A customTable containing letters outside {x,p,v} such as "xxbpvvvv" or digits like "12ppvvvv"; separators that are not plain spaces (e.g. hyphens or commas in "xx-pp-vvvv") are NOT stripped and will hit this error.

Common situations: Using hyphens or underscores as visual separators in the pattern; OCR/copy-paste introducing a wrong character; typing 'b' or 'o' instead of 'p'.

Related errors


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