GithubHelp home page GithubHelp logo

Comments (6)

ugorji avatar ugorji commented on July 18, 2024

why should this work?

from go.

aarondl avatar aarondl commented on July 18, 2024

Because it works for other data types, and an empty array has a strictly different nuance than a nil array.

from go.

ugorji avatar ugorji commented on July 18, 2024

my msgpack-fu is not on high right now. can you explain what the bytes mean? (ie what is test1 supposed to be?)

from go.

aarondl avatar aarondl commented on July 18, 2024

0x91 means an array of one object (this reflects the struct if created with StructToArray), 0x90 means empty array (the array of bytes).

If someone sends a message that contains an array of bytes normally, but it happens to be empty and rather than sending nil or nothing at all they send an empty array (0x90), the decoding fails.

from go.

ugorji avatar ugorji commented on July 18, 2024

Ah - got it now.

This is a corner case that may require code architecture changes to address.

When we decode, we look at the type of value you are decoding into, and then expect one of a set of ways to decode it.

If you have []Byte, or anything that resembles a sequence of bytes, we expect the stream the msgpack BinXXX or StrXXX. Let me look into adding the check for "if an array and len=0", before erroring out. Sending update soon.

from go.

ugorji avatar ugorji commented on July 18, 2024

A quick hack wasn't enough. Your position is strong. A []byte is also an array, and we should be able to decode it from a msgpack array, whether the length is 0 or not. My fix should cover that.

Thanks.

from go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.