Skip to content

Undefined encodes strangely and is unreadable by other libraries #18

@1egoman

Description

@1egoman

Steps to reproduce:

$ node
> let m = require('msgpack-js')
{ encode: [Function], decode: [Function: decode] }
> m.encode({foo: undefined, hello: 'world'})
<Buffer 82 a3 66 6f 6f c4 a5 68 65 6c 6c 6f a5 77 6f 72 6c 64>
> m.encode({foo: undefined, hello: 'world'}).toString('base64')
'gqNmb2/EpWhlbGxvpXdvcmxk'
$ python
Python 2.7.9 (default, Dec  1 2016, 15:15:08) 
[GCC 5.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import msgpack
>>> import base64
>>> a = base64.b64decode('gqNmb2/EpWhlbGxvpXdvcmxk')                                                                                       
>>> msgpack.unpackb(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "msgpack/_unpacker.pyx", line 145, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:145)
msgpack.exceptions.UnpackValueError: Unpack failed: error = 0
>>> 

Even if undefined isn't part of the msgpack spec, this is weird behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions