Skip to content

Commit 270e6af

Browse files
committed
merge prerelease branch
1 parent bbac279 commit 270e6af

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

ldcontext/context_easyjson.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ func unmarshalSingleKindEasyJSON(c *Context, in *jlexer.Lexer, knownKind Kind, u
161161
case ldattr.AnonymousAttr:
162162
c.anonymous = in.Bool()
163163
case jsonPropMeta:
164+
if in.IsNull() {
165+
in.Skip()
166+
break
167+
}
164168
in.Delim('{')
165169
for !in.IsDelim('}') {
166170
key := in.UnsafeBytes() // see comment above
@@ -271,6 +275,11 @@ func unmarshalOldUserSchemaEasyJSON(c *Context, in *jlexer.Lexer, usingEventForm
271275
c.anonymous = in.Bool()
272276
}
273277
case jsonPropOldUserCustom:
278+
if in.IsNull() {
279+
in.Skip()
280+
attributes = ldvalue.ValueMapBuilder{}
281+
break
282+
}
274283
in.Delim('{')
275284
for !in.IsDelim('}') {
276285
name := in.String()
@@ -288,15 +297,15 @@ func unmarshalOldUserSchemaEasyJSON(c *Context, in *jlexer.Lexer, usingEventForm
288297
case jsonPropOldUserPrivate:
289298
if usingEventFormat {
290299
in.SkipRecursive()
291-
continue
300+
break
292301
}
293302
readPrivateAttributesEasyJSON(in, c, true)
294303
// The "true" here means to interpret the strings as literal attribute names, since the
295304
// attribute reference path syntax was not used in the old user schema.
296305
case jsonPropOldUserRedacted:
297306
if !usingEventFormat {
298307
in.SkipRecursive()
299-
continue
308+
break
300309
}
301310
readPrivateAttributesEasyJSON(in, c, true)
302311
case "firstName", "lastName", "email", "country", "avatar", "ip":

ldcontext/context_unmarshaling.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func unmarshalSingleKind(c *Context, r *jreader.Reader, knownKind Kind, usingEve
114114
case ldattr.AnonymousAttr:
115115
b.Anonymous(r.Bool())
116116
case jsonPropMeta:
117-
for metaObj := r.Object(); metaObj.Next(); {
117+
for metaObj := r.ObjectOrNull(); metaObj.Next(); {
118118
switch string(metaObj.Name()) {
119119
case jsonPropSecondary:
120120
b.OptSecondary(readOptString(r))
@@ -187,7 +187,7 @@ func unmarshalOldUserSchema(c *Context, r *jreader.Reader, usingEventFormat bool
187187
value, _ := r.BoolOrNull()
188188
b.Anonymous(value)
189189
case jsonPropOldUserCustom:
190-
for customObj := r.Object(); customObj.Next(); {
190+
for customObj := r.ObjectOrNull(); customObj.Next(); {
191191
name := string(customObj.Name())
192192
var value ldvalue.Value
193193
value.ReadFromJSONReader(r)

ldcontext/context_unmarshaling_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func makeContextUnmarshalUnimportantVariantsParams() []contextSerializationParam
3333
{NewBuilder("my-key").Build(),
3434
`{"kind": "user", "key": "my-key", "_meta": {}}`},
3535

36+
// _meta: null is same as no _meta
37+
{NewBuilder("my-key").Build(),
38+
`{"kind": "user", "key": "my-key", "_meta": null}`},
39+
3640
// privateAttributes: [] is same as no privateAttributes
3741
{NewBuilder("my-key").Build(),
3842
`{"kind": "user", "key": "my-key", "_meta": {"privateAttributes": null}}`},
@@ -78,6 +82,10 @@ func makeContextUnmarshalFromOldUserSchemaParams() []contextSerializationParams
7882
{NewBuilder("key4").Build(),
7983
`{"key": "key4", "anonymous": null}`},
8084

85+
{NewBuilder("key6").Build(),
86+
`{"key": "key6", "custom": {}}`},
87+
{NewBuilder("key6").Build(),
88+
`{"key": "key6", "custom": null}`},
8189
{NewBuilder("key6").Build(),
8290
`{"key": "key6", "custom": {"attr1": null}}`},
8391
{NewBuilder("key6").SetBool("attr1", true).Build(),

0 commit comments

Comments
 (0)