vitessio/vitess · error
unreachable
Error message
unreachable
What it means
weightStringUnicode pads each codepoint's weight in the unicode (uci) layout and handles padding widths 0-2; any other width is impossible by construction. Hitting panic("unreachable") means an internal invariant broke — the padding width derived from the collation's weight table exceeded the expected range.
Source
Thrown at go/mysql/collations/colldata/unicode.go:263
break
}
src = src[width:]
dst = append(dst, byte((r>>16)&0xFF), byte((r>>8)&0xFF), byte(r&0xFF))
}
if numCodepoints == PadToMax {
for len(dst)+2 < cap(dst) {
dst = append(dst, 0x00, 0x00, 0x20)
}
switch cap(dst) - len(dst) {
case 0:
case 1:
dst = append(dst, 0x00)
case 2:
dst = append(dst, 0x00, 0x00)
default:
panic("unreachable")
}
}
} else {
for numCodepoints > 0 {
r, width, ok := cs.DecodeRune(src)
if !ok {
break
}
src = src[width:]
dst = append(dst, byte((r>>16)&0xFF), byte((r>>8)&0xFF), byte(r&0xFF))
numCodepoints--
}
for numCodepoints > 0 {
dst = append(dst, 0x00, 0x00, 0x20)
numCodepoints--
}
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Rebuild from a clean checkout — regenerated collation tables are likely out of sync with the code
- If a custom collation was added, fix its weight widths so each codepoint's weight list yields at most 2 padding bytes
- Report as a bug with the collation name and input string if stock collations trigger it
Defensive patterns
Strategy: fallback
Try / catch
defer func() {
if r := recover(); r != nil {
log.Warn("unicode WeightString invariant failure", slog.Any("panic", r))
// fall back to a safe hash or propagate an error
}
}() Prevention
- Never hand-edit generated collation weight tables
- Rebuild from clean checkout if collation data was regenerated
- Report stock-collation occurrences as bugs
When it happens
Trigger: Calling WeightString on a unicode-layout collation whose generated weight data yields a padding case other than 0, 1, or 2 — i.e. corrupted or hand-edited collation tables, or a custom collation built with wrong weight widths.
Common situations: Running a custom-built Vitess binary with regenerated collation tables that don't match the generated code; modifying uca/unicode table generation scripts incorrectly.
Related errors
- WeightStringLen called with non-MOD4 length
- len(p.Patch)%3
- This should never happen.
- bad unsigned integer type
- bad type aggregation for signed/unsigned types
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/ee63cb7cb693a80d.
Report an issue: GitHub.