Skip to content

Commit f1d26a2

Browse files
authored
Merge pull request #13 from hashicorp/paddy_better_errors_msgpack
Fix bug in msgpack invalid value error.
2 parents 0f5e723 + f20d81a commit f1d26a2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tfprotov5/tftypes/value_msgpack.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func marshalMsgPack(val Value, typ Type, p AttributePath, enc *msgpack.Encoder)
5151
func marshalMsgPackDynamicPseudoType(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
5252
dst, ok := val.value.(Value)
5353
if !ok {
54-
return unexpectedValueTypeError(p, Value{}, val, typ)
54+
return unexpectedValueTypeError(p, Value{}, val.value, typ)
5555
}
5656
typeJSON, err := dst.typ.MarshalJSON()
5757
if err != nil {
@@ -75,7 +75,7 @@ func marshalMsgPackDynamicPseudoType(val Value, typ Type, p AttributePath, enc *
7575
func marshalMsgPackString(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
7676
s, ok := val.value.(string)
7777
if !ok {
78-
return unexpectedValueTypeError(p, s, val, typ)
78+
return unexpectedValueTypeError(p, s, val.value, typ)
7979
}
8080
err := enc.EncodeString(s)
8181
if err != nil {
@@ -93,7 +93,7 @@ func marshalMsgPackNumber(val Value, typ Type, p AttributePath, enc *msgpack.Enc
9393
// advantage of that...
9494
n, ok := val.value.(*big.Float)
9595
if !ok {
96-
return unexpectedValueTypeError(p, n, val, typ)
96+
return unexpectedValueTypeError(p, n, val.value, typ)
9797
}
9898
if iv, acc := n.Int64(); acc == big.Exact {
9999
err := enc.EncodeInt(iv)
@@ -117,7 +117,7 @@ func marshalMsgPackNumber(val Value, typ Type, p AttributePath, enc *msgpack.Enc
117117
func marshalMsgPackBool(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
118118
b, ok := val.value.(bool)
119119
if !ok {
120-
return unexpectedValueTypeError(p, b, val, typ)
120+
return unexpectedValueTypeError(p, b, val.value, typ)
121121
}
122122
err := enc.EncodeBool(b)
123123
if err != nil {
@@ -129,7 +129,7 @@ func marshalMsgPackBool(val Value, typ Type, p AttributePath, enc *msgpack.Encod
129129
func marshalMsgPackList(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
130130
l, ok := val.value.([]Value)
131131
if !ok {
132-
return unexpectedValueTypeError(p, l, val, typ)
132+
return unexpectedValueTypeError(p, l, val.value, typ)
133133
}
134134
err := enc.EncodeArrayLen(len(l))
135135
if err != nil {
@@ -149,7 +149,7 @@ func marshalMsgPackList(val Value, typ Type, p AttributePath, enc *msgpack.Encod
149149
func marshalMsgPackSet(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
150150
s, ok := val.value.([]Value)
151151
if !ok {
152-
return unexpectedValueTypeError(p, s, val, typ)
152+
return unexpectedValueTypeError(p, s, val.value, typ)
153153
}
154154
err := enc.EncodeArrayLen(len(s))
155155
if err != nil {
@@ -169,7 +169,7 @@ func marshalMsgPackSet(val Value, typ Type, p AttributePath, enc *msgpack.Encode
169169
func marshalMsgPackMap(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
170170
m, ok := val.value.(map[string]Value)
171171
if !ok {
172-
return unexpectedValueTypeError(p, m, val, typ)
172+
return unexpectedValueTypeError(p, m, val.value, typ)
173173
}
174174
err := enc.EncodeMapLen(len(m))
175175
if err != nil {
@@ -193,7 +193,7 @@ func marshalMsgPackMap(val Value, typ Type, p AttributePath, enc *msgpack.Encode
193193
func marshalMsgPackTuple(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
194194
t, ok := val.value.([]Value)
195195
if !ok {
196-
return unexpectedValueTypeError(p, t, val, typ)
196+
return unexpectedValueTypeError(p, t, val.value, typ)
197197
}
198198
types := typ.(Tuple).ElementTypes
199199
err := enc.EncodeArrayLen(len(types))
@@ -215,7 +215,7 @@ func marshalMsgPackTuple(val Value, typ Type, p AttributePath, enc *msgpack.Enco
215215
func marshalMsgPackObject(val Value, typ Type, p AttributePath, enc *msgpack.Encoder) error {
216216
o, ok := val.value.(map[string]Value)
217217
if !ok {
218-
return unexpectedValueTypeError(p, o, val, typ)
218+
return unexpectedValueTypeError(p, o, val.value, typ)
219219
}
220220
types := typ.(Object).AttributeTypes
221221
keys := make([]string, 0, len(types))

0 commit comments

Comments
 (0)