{"record":{"id":"1384211c527963c2","repo":"vitessio/vitess","slug":"len-p-patch-3","errorCode":null,"errorMessage":"len(p.Patch)%3","messagePattern":"len\\(p\\.Patch\\)%3","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/collations/internal/uca/layout.go","lineNumber":137,"sourceCode":"\t\treturn nil\n\t}\n\n\tceCount := int((*page)[offset])\n\tfor ce := range ceCount {\n\t\tresult = append(result,\n\t\t\t(*page)[256+(ce*3+0)*256+offset],\n\t\t\t(*page)[256+(ce*3+1)*256+offset],\n\t\t\t(*page)[256+(ce*3+2)*256+offset],\n\t\t)\n\t}\n\treturn\n}\n\nfunc (Layout_uca900) allocPage(original *[]uint16, patches []Patch) []uint16 {\n\tvar maxWeights int\n\tfor _, p := range patches {\n\t\tif len(p.Patch)%3 != 0 {\n\t\t\tpanic(\"len(p.Patch)%3\")\n\t\t}\n\t\tif len(p.Patch) > maxWeights {\n\t\t\tmaxWeights = len(p.Patch)\n\t\t}\n\t}\n\n\tminLenForPage := maxWeights*CodepointsPerPage + CodepointsPerPage\n\tif original == nil {\n\t\treturn make([]uint16, minLenForPage)\n\t}\n\tif len(*original) > minLenForPage {\n\t\tminLenForPage = len(*original)\n\t}\n\tnewPage := make([]uint16, minLenForPage)\n\tcopy(newPage, *original)\n\treturn newPage\n}\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/collations/internal/uca/layout.go#L119-L155","documentation":"Layout_uca900.allocPage validates that each Patch's Patch slice length is a multiple of 3 (primary, secondary, tertiary weights per collation element). A non-multiple-of-3 patch means the patch data is malformed. This is a startup/initialization-time panic protecting the generated collation tables.","triggerScenarios":"Building or regenerating UCA 900 collation pages with patch data whose []uint16 length is not divisible by 3 — i.e. a malformed entry in the collation patch tables (colldata generated files).","commonSituations":"Editing go/mysql/collations generated data by hand; custom collation development where patch definitions were typed incorrectly.","solutions":["Fix the patch data so each entry has exactly 3 uint16s per collation element (primary, secondary, tertiary)","Regenerate collation tables via the codegen pipeline instead of editing generated files","Restore the original generated colldata files from a clean checkout"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for _, p := range patches {\n\tif len(p.Patch)%3 != 0 {\n\t\treturn fmt.Errorf(\"patch %q has invalid weight length %d\", p.Prefix, len(p.Patch))\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define patches only through the codegen pipeline","Keep each patch entry as complete primary/secondary/tertiary triples","Restore generated colldata files instead of editing them"],"tags":["panic","collations","codegen","data-integrity"],"backgroundTag":"malformed-collation-patch-data","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}