{"record":{"id":"da058bb6f60614cc","repo":"vitessio/vitess","slug":"no-string-value-found-for-enum-column-s-in-table","errorCode":null,"errorMessage":"no string value found for ENUM column %s in table %s -- with available values being: %v -- using the found integer value: %d","messagePattern":"no string value found for ENUM column (.+?) in table (.+?) -- with available values being: (.+?) -- using the found integer value: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletserver/vstreamer/vstreamer.go","lineNumber":1452,"sourceCode":"\t\t}\n\t}\n\t// ENUM columns are stored as an unsigned 16-bit integer as they can contain a maximum\n\t// of 65,535 elements (https://dev.mysql.com/doc/refman/en/enum.html) with the 0 element\n\t// reserved for any integer value that has no string mapping.\n\tiv, err := value.ToUint16()\n\tif err != nil {\n\t\treturn sqltypes.Value{}, vterrors.Wrapf(err, \"no valid integer value found for column %s in table %s, bytes: %b\",\n\t\t\tplan.Table.Fields[colNum].Name, plan.Table.Name, iv)\n\t}\n\tvar strVal string\n\t// Match the MySQL behavior of returning an empty string for invalid ENUM values.\n\t// This is what the 0 position in an ENUM is reserved for.\n\tif iv != 0 {\n\t\tvar ok bool\n\t\tstrVal, ok = plan.EnumSetValuesMap[colNum][int(iv)]\n\t\tif !ok {\n\t\t\t// The integer value was NOT 0 yet we found no mapping. This should never happen.\n\t\t\treturn sqltypes.Value{}, fmt.Errorf(\"no string value found for ENUM column %s in table %s -- with available values being: %v -- using the found integer value: %d\",\n\t\t\t\tplan.Table.Fields[colNum].Name, plan.Table.Name, plan.EnumSetValuesMap[colNum], iv)\n\t\t}\n\t}\n\treturn sqltypes.MakeTrusted(plan.Table.Fields[colNum].Type, []byte(strVal)), nil\n}\n\n// buildSetStringValue takes the integer value of a SET column and returns the string value.\nfunc buildSetStringValue(env *vtenv.Environment, plan *streamerPlan, colNum int, value sqltypes.Value) (sqltypes.Value, error) {\n\tif value.IsNull() { // No work is needed\n\t\treturn value, nil\n\t}\n\t// Add the mappings just-in-time in case we haven't properly received and processed a\n\t// table map event to initialize it.\n\tif plan.EnumSetValuesMap == nil {\n\t\tif err := addEnumAndSetMappingstoPlan(env, plan.Plan, plan.Table.Fields, plan.TableMap.Metadata); err != nil {\n\t\t\treturn sqltypes.Value{}, vterrors.Wrap(err, \"failed to build SET column integer to string mappings\")\n\t\t}\n\t}","sourceCodeStart":1434,"sourceCodeEnd":1470,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/vstreamer/vstreamer.go#L1434-L1470","documentation":"When decoding an ENUM value, the integer stored in the row is used as an index into the column's value map. If a non-zero integer has no corresponding string entry, the mapping is internally inconsistent (index 0 is reserved for the empty ENUM value), so vstreamer refuses to fabricate a value and returns this diagnostic listing the available mappings.","triggerScenarios":"buildEnumStringValue looks up plan.EnumSetValuesMap[colNum][int(iv)] for iv != 0 and the key is missing, meaning the row's enum index exceeds the entries derived from the current ColumnType definition.","commonSituations":"The ENUM definition was shrunk or reordered after the row was written, so old row indexes don't match the current value list; schema cache with a truncated enum() list; corrupt/foreign row data.","solutions":["Restore the original ENUM definition (same values, same order) so historical indexes map correctly","Reload the table schema so EnumSetValuesMap is built from the correct ColumnType","Use --track-schema-versions to decode with the schema version contemporaneous with the rows","Re-copy or rewrite affected rows if the enum values were intentionally changed"],"exampleFix":"// before\nALTER TABLE t MODIFY c ENUM('b','c');\n// after (restore order/values matching historical rows)\nALTER TABLE t MODIFY c ENUM('a','b','c');","handlingStrategy":"validation","validationCode":"// Verify enum values match historical data:\n// SHOW COLUMNS FROM <t> LIKE '<c>'; -- compare enum('...') list to what rows were written with","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"no string value found for ENUM column\") {\n    // restore original enum ordering/values or decode with the matching schema version\n}","preventionTips":["Never reorder or shrink ENUM lists in place; append new values at the end","Use --track-schema-versions for historical row decode","Test ALTERs on ENUM columns against vreplicated copies first"],"tags":["enum","value-mapping","schema-history","vstreamer"],"backgroundTag":"enum-set-value-mapping-missing","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}