Bug #91503 NodeJS Extra padding on string fields and error on JSON field
Submitted: 29 Jun 2018 13:27 Modified: 31 Aug 2018 17:54
Reporter: Gabriela Ferrara Email Updates:
Status: Closed Impact on me:
Category:Connector for Node.js Severity:S2 (Serious)
Version:8.0.11 OS:Any
Assigned to: CPU Architecture:Any

[29 Jun 2018 13:27] Gabriela Ferrara
NodeJS connector is padding strings and if you have JSON NOT NULL field it gives an error. If the JSON field is nullable, the error doesn't occur, just the padding.

How to repeat:
Run the following code:


const mysqlx = require('@mysql/xdevapi')

mysqlx.getSession({ user: 'root', schema: 'testcase' })
  .then(session => {
    return session.sql('USE testcase').execute()
      .then(() => {
        return session.sql('CREATE TABLE test (id MEDIUMINT NOT NULL AUTO_INCREMENT, doc JSON NOT NULL, PRIMARY KEY (id))')
      .then(() => {
        return session.sql(`INSERT INTO test (doc) VALUES ('{"name":"foo","age":42}')`)
      .then(() => {
        return session.getSchema('testcase').getTable('test').select(['id', 'doc'])
      .then(() => {
        return session.dropSchema('testcase')
      .then(() => {
        return session.close()
  .catch(err => {


 node test.js
    return asString.concat(char.repeat(size - maxSize));

RangeError: Invalid string length
    at String.repeat (<anonymous>)
    at rightPad (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/Protocol/Protobuf/Adapters/Resultset.js:490:33)
    at decodeOpaqueByteString (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/Protocol/Protobuf/Adapters/Resultset.js:224:16)
    at decodeField (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/Protocol/Protobuf/Adapters/Resultset.js:167:16)
    at proto.getFieldList.map (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/Protocol/Protobuf/Adapters/Resultset.js:573:32)
    at Array.map (<anonymous>)
    at Object.exports.decodeRow (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/Protocol/Protobuf/Adapters/Resultset.js:573:10)
    at SqlResultHandler.(anonymous function) (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/Protocol/ResponseHandlers/SqlResultHandler.js:110:27)
    at Array.entry (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/Protocol/ResponseHandlers/BaseHandler.js:90:29)
    at WorkQueue.process (~/Public/cloud-functions/node_modules/@mysql/xdevapi/lib/WorkQueue.js:75:19)
[2 Jul 2018 6:09] MySQL Verification Team
Hello Gabriela,

Thank you for the report!

[31 Aug 2018 17:54] Philip Olson
Posted by developer:
Thank you for the bug report, this was fixed in 8.0.12 via a different bug. It appears that this report was missed or overlooked. 

The 8.0.12 changelog entry reads as follows:

    The right-padding mechanism was improved.