{"record":{"id":"53cb2cfd2739a834","repo":"XTLS/Xray-core","slug":"customtable-must-contain-exactly-2-x-2-p-and-4-v","errorCode":null,"errorMessage":"customTable must contain exactly 2 x, 2 p and 4 v","messagePattern":"customTable must contain exactly 2 x, 2 p and 4 v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"transport/internet/finalmask/sudoku/table.go","lineNumber":199,"sourceCode":"\tif len(cleaned) != 8 {\n\t\treturn \"\", fmt.Errorf(\"customTable must be 8 chars, got %d\", len(cleaned))\n\t}\n\n\tvar xCount, pCount, vCount int\n\tfor _, ch := range cleaned {\n\t\tswitch ch {\n\t\tcase 'x':\n\t\t\txCount++\n\t\tcase 'p':\n\t\t\tpCount++\n\t\tcase 'v':\n\t\t\tvCount++\n\t\tdefault:\n\t\t\treturn \"\", fmt.Errorf(\"customTable has invalid char %q\", ch)\n\t\t}\n\t}\n\tif xCount != 2 || pCount != 2 || vCount != 4 {\n\t\treturn \"\", fmt.Errorf(\"customTable must contain exactly 2 x, 2 p and 4 v\")\n\t}\n\treturn cleaned, nil\n}\n\nfunc resolveLayout(mode, customTable string) (*byteLayout, error) {\n\tif mode == \"prefer_ascii\" {\n\t\treturn asciiLayout(), nil\n\t}\n\n\tif customTable != \"\" {\n\t\treturn customLayout(customTable)\n\t}\n\treturn entropyLayout(), nil\n}\n\nfunc asciiLayout() *byteLayout {\n\tpadding := make([]byte, 0, 32)\n\tfor i := 0; i < 32; i++ {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/transport/internet/finalmask/sudoku/table.go#L181-L217","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the pattern contains exactly two x, two p, and four v characters in any order.","Start from the canonical \"xxppvvvv\" and permute positions only.","Leave customTable empty to use the default layout if the exact arrangement is not important."],"exampleFix":"// before\n\"customTable\": \"xxxppvvv\"\n// after\n\"customTable\": \"xxppvvvv\"","handlingStrategy":"validation","validationCode":"func validCustomTable(pattern string) bool {\n\tp := strings.ReplaceAll(strings.ToLower(strings.TrimSpace(pattern)), \" \", \"\")\n\tif len(p) != 8 {\n\t\treturn false\n\t}\n\tvar x, q, v int\n\tfor _, ch := range p {\n\t\tswitch ch {\n\t\tcase 'x': x++\n\t\tcase 'p': q++\n\t\tcase 'v': v++\n\t\tdefault: return false\n\t\t}\n\t}\n\treturn x == 2 && q == 2 && v == 4\n}\n\nif !validCustomTable(cfg.CustomTable) {\n\treturn errors.New(\"reject config: customTable must have 2 x, 2 p, 4 v\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the 2/2/4 composition check in config validation before dialing.","Permuting a known-good pattern is safe; changing letter counts is not."],"tags":["config","validation","finalmask","sudoku"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}