Comments (6)
why should this work?
from go.
Because it works for other data types, and an empty array has a strictly different nuance than a nil array.
from go.
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.
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.
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.
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)
- Vulnerability Issue - CWE 74 External Control of File Name or Path HOT 3
- unable to restore original data while using map[string]interface{} HOT 1
- omitempty handling for arrays disagrees with the standard encoding/json HOT 2
- codec.MsgpackHandle.RawToString is confusingly named HOT 2
- Go 1.20 - invalid memory address or nil pointer dereference HOT 5
- Msgpack deserialization with codecgen produces wrong result HOT 3
- Unexpected encoding with interface{} key using Canonical and MapKeyAsString.
- Decoding a slice of structs encoded as arrays into a slice of structs without the same number of fields HOT 2
- Duplicate key inside of a map triggers a "cannot decode unsigned integer" msgpack decode error HOT 1
- Efficient direct conversion between supported formats? HOT 2
- Expose Handle.Name() in some form through Encoder and Decoder for use by codec.Selfer HOT 1
- `io.ErrUnexpectedEOF` should be returned instead of `io.EOF` when only partial data is present
- Add `DecodeOptions.IntType` and `DecodeOptions.FloatType` ? HOT 1
- Docs do not seem to mention case-sensitive field handling
- mem leak? HOT 1
- Tests use rand.Intn(1) for boolean rand, but always returns 0
- Decoder accepts indefinite-length CBOR strings containing chunks with mismatched major types HOT 1
- UTF-8 validation isn't applied to CBOR text strings nested inside an indefinite-length text string HOT 2
- Add support for github.com/go-json-experiment/json / UnmarshalerV2 ? HOT 1
- runtime error with golang master (furture go 1.22)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.