{"record":{"id":"04d4f8a230cf08c1","repo":"vitessio/vitess","slug":"invalid-coercibility-value","errorCode":null,"errorMessage":"invalid Coercibility value","messagePattern":"invalid Coercibility value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/collations/coercion.go","lineNumber":79,"sourceCode":"\nfunc (ci Coercibility) String() string {\n\tswitch ci {\n\tcase 0:\n\t\treturn \"EXPLICIT\"\n\tcase 1:\n\t\treturn \"NONE\"\n\tcase 2:\n\t\treturn \"IMPLICIT\"\n\tcase 3:\n\t\treturn \"SYSCONST\"\n\tcase 4:\n\t\treturn \"COERCIBLE\"\n\tcase 5:\n\t\treturn \"NUMERIC\"\n\tcase 6:\n\t\treturn \"IGNORABLE\"\n\tdefault:\n\t\tpanic(\"invalid Coercibility value\")\n\t}\n}\n\n// Repertoire is a constant that defines the collection of characters in an expression.\n// MySQL only distinguishes between an ASCII repertoire (i.e. an expression where all\n// the contained codepoints are < 128), or an Unicode repertoire (an expression that\n// can contain any possible codepoint).\n//\n// See: https://dev.mysql.com/doc/refman/8.0/en/charset-repertoire.html\ntype Repertoire byte\n\nconst (\n\tRepertoireASCII Repertoire = iota\n\tRepertoireUnicode\n)\n\n// TypedCollation is the Collation of a SQL expression, including its coercibility\n// and repertoire.","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/collations/coercion.go#L61-L97","documentation":"TypedCollation.String() (Collation's coercibility name method) panics when the Coercibility value is outside the defined 0-6 range. Coercibility is a small enum describing collation precedence; an out-of-range value means the value was constructed or deserialized incorrectly.","triggerScenarios":"Calling String() on a Coercibility value > 6 (or negative), typically from a corrupt/uninitialized TypedCollation, a bad bit-unpack, or a manually constructed Coercibility with an invalid integer.","commonSituations":"Debug printing of TypedCollation values decoded from an int32 that was corrupted; hand-written constants that don't match the enum; bit-packing bugs in code that serializes TypedCollation.","solutions":["Check where the Coercibility value was produced; fix the packing/unpacking or initialization code.","Only construct Coercibility from the defined constants (CoercibilityExplicit ... CoercibilityIgnorable).","Add a validation in the constructor/deserializer to reject out-of-range values with a proper error."],"exampleFix":"// before\nc := Collation{Coercibility: Coercibility(9)}\nfmt.Println(c.Coercibility) // panics\n// after\nc := Collation{Coercibility: CoercibilityIgnorable}\nfmt.Println(c.Coercibility) // \"IGNORABLE\"","handlingStrategy":"validation","validationCode":"func validCoercibility(c collations.Coercibility) bool {\n    return c >= collations.CoercibilityExplicit && c <= collations.CoercibilityIgnorable\n}","typeGuard":null,"tryCatchPattern":"func safeString(c collations.Coercibility) (s string) {\n    defer func() {\n        if r := recover(); r != nil {\n            s = fmt.Sprintf(\"INVALID_COERCIBILITY(%d)\", int(c))\n        }\n    }()\n    return c.String()\n}","preventionTips":["Only build Coercibility values from the exported constants, never raw ints.","Validate any Coercibility decoded from a serialized int32 against the 0-6 range.","Write a table-driven test that calls String() on every defined constant to catch range drift."],"tags":["collations","enum","panics","api-misuse"],"backgroundTag":"invalid-enum-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}