Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utf8 decoding error. #19

Open
roipeker opened this issue Jul 13, 2019 · 1 comment
Open

Utf8 decoding error. #19

roipeker opened this issue Jul 13, 2019 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@roipeker
Copy link

roipeker commented Jul 13, 2019

No clue what to do... lib seems very unreliable. I'm running a
INSERT IGNORE INTO product () VALUES ()
for 8000 records... it fails using connection::query(), works fine in queryMulti(), so i thought it would be the length of the query string... my sweet spot was 315 records at a time in a single query... max query length at 39100 characters. Otherwise, same exception.

After truncate the product table, i was able to run the query() with the 8k products without errors... I just don't understand how the buffer.readString() gets corrupted on particular cases.
This is the exception:

[SEVERE] FormatException: Bad UTF-8 encoding 0xb8 (at offset 0) #0      _Utf8Decoder.convert (dart:convert/utf.dart:530:13)
#1      Utf8Decoder.convert (dart:convert/utf.dart:327:13)
#2      Utf8Codec.decode (dart:convert/utf.dart:59:56)
#3      Buffer.readString (package:mysql1/src/buffer.dart:178:21)
#4      Buffer.readStringToEnd (package:mysql1/src/buffer.dart:172:31)
#5      new OkPacket (package:mysql1/src/handlers/ok_packet.dart:21:23)
#6      Handler.checkResponse (package:mysql1/src/handlers/handler.dart:80:28)
#7      QueryStreamHandler.processResponse (package:mysql1/src/query/query_stream_handler.dart:49:18)
#8      ReqRespConnection._handleData (package:mysql1/src/single_connection.dart:329:31)### 

Right after posting the issue... I saw that utf8.decode() has a malformed param. Seems to fix the error:

// buffer.dart (line 178)
String s = utf8.decode(_list.sublist(_readPos, _readPos + length),allowMalformed: true);

Please, keep updating the package... is currently the only solution available for Dart.

@adamlofts
Copy link
Owner

The docs don't mention the encoding of this field so it is possible that we should not be trying to decode utf at all.

https://dev.mysql.com/doc/internals/en/describing-packets.html#type-string.EOF

This field is only used for display so I think your fix is fine. Please submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants