{"record":{"id":"60405304256a642b","repo":"vitessio/vitess","slug":"invalid-signature-for-ucptrie-0x-08x","errorCode":null,"errorMessage":"invalid signature for UcpTrie: 0x%08x","messagePattern":"invalid signature for UcpTrie: 0x%08x","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/icuregex/internal/utrie/ucptrie.go","lineNumber":269,"sourceCode":"\t\t/** Data null block offset bits 15..0, 0xfffff if none. */\n\t\tdataNullOffset uint16\n\n\t\t/**\n\t\t * First code point of the single-value range ending with U+10ffff,\n\t\t * rounded up and then shifted right by UCPTRIE_SHIFT_2.\n\t\t */\n\t\tshiftedHighStart uint16\n\t}\n\n\tvar header ucpHeader\n\theader.signature = bytes.Uint32()\n\n\tswitch header.signature {\n\tcase ucpTrieSig:\n\tcase ucpTrieOESig:\n\t\treturn nil, errors.New(\"unsupported: BigEndian encoding\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid signature for UcpTrie: 0x%08x\", header.signature)\n\t}\n\n\theader.options = bytes.Uint16()\n\theader.indexLength = bytes.Uint16()\n\theader.dataLength = bytes.Uint16()\n\theader.index3NullOffset = bytes.Uint16()\n\theader.dataNullOffset = bytes.Uint16()\n\theader.shiftedHighStart = bytes.Uint16()\n\n\ttypeInt := (header.options >> 6) & 3\n\tvalueWidthInt := header.options & optionsValueBitsMask\n\tif typeInt > uint16(typeSmall) || valueWidthInt > uint16(valueBits8) ||\n\t\t(header.options&optionsReservedMask) != 0 {\n\t\treturn nil, errors.New(\"invalid options for serialized UcpTrie\")\n\t}\n\tactualType := ucpTrieType(typeInt)\n\tactualValueWidth := ucpTrieValueWidth(valueWidthInt)\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/icuregex/internal/utrie/ucptrie.go#L251-L287","documentation":"UcpTrieFromBytes deserializes a precompiled ICU UcpTrie from its binary form and expects the first 4 bytes to be one of the known little-endian signatures (Trie3/Trie4, 0x54726933/0x54726934-style). An unrecognized signature means the byte slice is not a serialized UcpTrie produced by the matching ICU version/format - it is truncated, corrupted, or an entirely different data blob.","triggerScenarios":"Calling UcpTrieFromBytes (via load/readData in the icuregex package) with data whose leading uint32 does not match ucpTrieSig, typically because the embedded trie binary is missing, truncated, or was built/serialized by an incompatible ICU or codegen version.","commonSituations":"Corrupted or partially-copied generated data files in the icuregex internal tables, codegen output from a mismatched ICU version after an ICU upgrade, or a build/packaging issue where the binary asset was replaced or zero-filled.","solutions":["Regenerate the serialized trie data with the project's codegen (make codegen / the icuregex generation step) so the signature matches what this deserializer expects.","Verify the byte slice is complete and uncorrupted (check length and that the first 4 bytes are the expected little-endian Trie3/Trie4 signature).","If the data was produced by a newer ICU with a changed format, upgrade the internal/utrie deserializer (or pin the ICU codegen version) - note BigEndian-encoded tries are explicitly unsupported and raise a separate error."],"exampleFix":"// before\ndata := readBundledFile(\"caseProps.trie\") // truncated/corrupt\ntrie, err := utrie.UcpTrieFromBytes(data)\n// after\nif len(data) < 4 || binary.LittleEndian.Uint32(data[:4]) != utrie.ExpectedSignature {\n    return vterrors.Errorf(vtrpcpb.Code_INTERNAL, \"embedded UcpTrie data missing or has invalid signature\")\n}\ntrie, err := utrie.UcpTrieFromBytes(data)","handlingStrategy":"validation","validationCode":"func validUcpTrieBlob(data []byte) bool {\n    if len(data) < 4 {\n        return false\n    }\n    sig := binary.LittleEndian.Uint32(data[:4])\n    return sig == utrie.ExpectedLittleEndianSignature // verify against the package's ucpTrieSig constant\n}","typeGuard":null,"tryCatchPattern":"trie, err := utrie.UcpTrieFromBytes(data)\nif err != nil {\n    return nil, vterrors.Wrapf(err, vtrpcpb.Code_INTERNAL, \"failed to load embedded UcpTrie data (codegen output stale or corrupted)\")\n}","preventionTips":["Regenerate embedded trie binaries via the project's codegen after ICU/generator upgrades.","Check file size and first-4-byte signature before deserializing bundled binary data.","Treat a signature error as a build/packaging problem, not a runtime input problem.","Ensure generated data files are not overwritten or truncated by build steps."],"tags":["icu","serialization","regex","binary-data"],"backgroundTag":"invalid-binary-format-signature","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}