{"record":{"id":"6f0c8d81ae38bbfd","repo":"vitessio/vitess","slug":"internal-value-v-to-mysql-value-error-v","errorCode":null,"errorMessage":"internal value %v to MySQL value error: %v","messagePattern":"internal value (.+?) to MySQL value error: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/query.go","lineNumber":1217,"sourceCode":"\n\tdata, pos := c.startEphemeralPacketWithHeader(length)\n\n\tpos = writeByte(data, pos, 0x00)\n\n\tfor range nullBitMapLen {\n\t\tpos = writeByte(data, pos, 0x00)\n\t}\n\n\tfor i, val := range row {\n\t\tif val.IsNull() {\n\t\t\tbytePos := (i+2)/8 + 1 + PacketHeaderSize\n\t\t\tbitPos := (i + 2) % 8\n\t\t\tdata[bytePos] |= 1 << uint(bitPos)\n\t\t} else {\n\t\t\tv, err := val2MySQL(val)\n\t\t\tif err != nil {\n\t\t\t\tc.recycleWritePacket()\n\t\t\t\treturn fmt.Errorf(\"internal value %v to MySQL value error: %v\", val, err)\n\t\t\t}\n\t\t\tpos += copy(data[pos:], v)\n\t\t}\n\t}\n\n\treturn c.writeEphemeralPacket()\n}\n\n// writeBinaryRows sends the rows of a Result with binary form.\nfunc (c *Conn) writeBinaryRows(result *sqltypes.Result) error {\n\tfor _, row := range result.Rows {\n\t\tif err := c.writeBinaryRow(result.Fields, row); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":1199,"sourceCodeEnd":1235,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/query.go#L1199-L1235","documentation":"After sizing the packet, writeBinaryRow converts each non-null value with val2MySQL; when conversion fails the write packet is recycled and this wrapped error is returned to the client. It means the value cannot be encoded into the MySQL binary result-set format.","triggerScenarios":"Same class of inputs as the length error (386): a row value whose type is unsupported by val2MySQL during binary row encoding for a prepared statement result.","commonSituations":"Unsupported vitess internal types reaching the wire encoder; schema/type mismatches after migrations; passing through MySQL types vitess does not encode.","solutions":["Cast the offending column to a supported type in the query","Verify field type metadata matches the values actually returned","Fix or extend val2MySQL support if this is a vitess-side gap"],"exampleFix":"// before\nSELECT payload FROM t // payload type unsupported in binary protocol\n// after\nSELECT CONVERT(payload, CHAR) AS payload FROM t","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := conn.WriteBinaryRows(fields, rows); err != nil {\n\tif strings.Contains(err.Error(), \"to MySQL value error\") {\n\t\t// retry with text protocol rendering or convert the value first\n\t}\n\treturn err\n}","preventionTips":["Avoid returning unsupported internal types over the binary protocol","Cast unsupported columns in SQL rather than relying on the wire encoder","Monitor for this error after schema/type migrations to catch passthrough gaps"],"tags":["mysql-protocol","serialization","wire-protocol"],"backgroundTag":"unsupported-column-type","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}