Skip to content

Commit dcd997e

Browse files
LaunchDarklyReleaseBoteli-darklyLaunchDarklyCIbwoskow-ldsamstokes
authored
prepare 3.0.1 release (#24)
* update release config * update release config * fix package references * add ldlog package to go-sdk-common * lint * drop Go 1.8-1.11 and update linter * gitignore * lint * add ldtime package for time helpers * add Go 1.14 in CI * desupport Go 1.12 * makefile improvement * make repo a module * don't install dep * yaml fix * update golangci-lint + misc code cleanup * add methods for detecting current log level * enforce consistent import groups * enable stylecheck, fix comment * add prerelease readme note * improve test coverage and enforce coverage goals (#18) * update readme note about import path, add godoc badge * better badge * omit unset properties in user JSON instead of serializing null value * don't allocate extra objects when setting user builder properties * add generic user attr setter and more Value helper methods * add benchmarks and enforce zero-allocation goals * implement streaming JSON serialization (#23) * fix bug in JSONBuffer state when writing zeroes * fix note about import path * go mod tidy * fix JSONBuffer string escaping, + slight refactor * remove accidental inclusions from another branch * lint * remove inapplicable comments * add ability to send buffered JSON output to another writer * add log test helper package * add UnmarshalText and other helper methods to OptionalString * use go-test-helpers v2 (removes unwanted eventsource dependency) (#28) * user unmarshaling should fail if key is missing (#30) * add OptionalInt type * test coverage * keep method signature of NewEvaluationDetail the same as it used to be * comment * add OptionalBool type and use it for User.Anonymous (#32) * add OptionalBool type and use it for User.Anonymous * comment * add ldlogtest helper for dumping captured log output * add Go 1.15 build and remove beta changelog * update Go version in readme * rm prerelease note * better error reporting when unmarshaling User, OptionalString, etc. (#35) * add IsDefined() methods to optional-like types * better copy-on-write behavior for maps/slices; expose map & array types * use new go-jsonstream API (#38) * change go-jsonstream import path back to gopkg.in since the repo is public now * add conditionally-compiled EasyJSON methods * update for go-jsonstream API changes * build in Windows with Go 1.14 * update CircleCI Windows image * treat null as equivalent to empty array for privateAttributeNames in user JSON * EasyJSON optimizations for ldvalue and lduser types (#43) * EasyJSON optimizations for ldvalue and lduser types * revert unnecessary changes to non-easyjson implementation * fix test (detection of trailing comma is not a well-defined use case) * require a JSON object (not null) when parsing a User * Removed the guides link * Add inExperiment attribute to FALLTHROUGH and RULE_MATCH reasons (#45) This adds an attribute inExperiment to reasons of kinds FALLTHROUGH and RULE_MATCH, as specified in the Experiment Traffic Allocation spec. This attribute is intended to indicate whether the user was targeted by an experiment rollout, and if so, whether they were allocated to one of the experiment variations. We currently plan to use this for two things: * to allow event consumers (currently, the experimentation pipeline and Data Export customers) to filter feature events to only those from users who are part of an experiment. * to allow some SDKs, which use reasons to determine whether to send full events, to avoid sending feature events in the first place after evaluating experiment rollouts for users who are not part of the experiment. (It might seem like this makes the filtering requirement redundant, since there's no need to filter out events that the SDKs declined to send in the first place, but for Data Export customers we want to send all of the events but still filter them for experiment analysis.) * Enable tests when releasing (#46) * Enable tests when releasing (#46) * add unbounded segments status to evaluation reasons (#44) * "big" is the new "unbounded" (#47) * update go-jsonstream version for ch110425 bugfix * update to newer Releaser config format, add Go 1.16 CI (#50) * update to newer Releaser config format, add Go 1.16 CI * run code coverage job in Go 1.15 * Updates docs URLs * add CI job for Go 1.17; update linter & test coverage script * remove deprecated old copy of jsonstream package * remove references to now-removed package * rm tests for obsolete package * (#1) basic context model/builders/constructors, not including private attrs (#55) * (#2) implement attribute reference parsing and lookup (#56) * (#4) add private attributes to context model (#61) * (#5) add JSON serialization and deserialization, including from old user format (#62) * (#6) reimplement UserBuilder to build Context (#64) * implementation of context serialization/redaction in events (to be moved to go-sdk-events) (#63) * add comparative benchmarks for v2 (#66) * add comparative benchmarks for v2 * DRY * add ldcontext benchmarks + alternate marshal/unmarshal methods (#65) * update major version and Go version * optimizations for context unmarshaling, especially with EasyJSON (#67) * move "transient" to top level, clarify distinction between attributes & meta * fix import path * change JSON prop name of "privateAttributeNames" to "privateAttributes" * fix import path * fix mistake in old user schema * add option to deserialize in event format; move special JSON APIs into their own type * revise implementation of previously-redacted attr list to be separate from private attrs * miscellaneous API & test coverage improvements * remove tempevents code * change ldcontext.AttrRef to ldattr.Ref * misc doc fixes * import ordering * rm unused * remove support for unmarshaling in "event output format" (#74) * stop using gopkg.in in import paths (#75) * stop using gopkg.in in import paths * update go-jsonstream import * miscellaneous ldvalue/ldcontext API improvements * add ldattr.Ref.Equal * don't allow marshaling of uninitialized Context * disallow empty string for kind in JSON * "multi-kind" context with 1 kind should become single-kind * comment * rename NewNameRef to NewLiteralRef * disallow use of escape character other than ~0 or ~1 * add marshaling/unmarshaling for "event context" * fix EasyJSON parser that failed to consume a closing curly brace; improve tests * ensure privateAttrs list is zeroed out initially; add "unmarshal twice" test * better accessor methods for individual contexts + IsDefined * further simplify: don't need 2nd return value now that we have IsDefined * transparently convert empty raw JSON value to null * fix linter in build * lint * rename "transient" back to "anonymous" * treat null as equivalent to {} when unmarshaling sub-objects from user/context JSON * export types for specific validation errors * clarify rules about custom attributes with same names as meta things * use percent-encoding for specific characters in fully-qualified key, not url.PathEscape * flatten nested multi-kind contexts when building a multi-kind context * doc comments * require Go 1.18 or higher; use generics * fix release configuration * use go-test-helpers 3.x * rm obsolete linter * update go-jsonstream dependency * attribute ref components are always properties, not array indices * indents * disallow setting "secondary" in contexts (but still support it internally for old user JSON) * add ldvalue.FromJSONMarshal, improve behavior of complex types & raw type * reduce boilerplate code in ldvalue using generics * consistent support for MarshalText/UnmarshalText * add another test case * big copyedit of doc comments + Go 1.19 formatting * don't add any methods in this PR * add Context.JSONString() * add Context.JSONString * lint: consistent receiver names * typo * fix comment * Remove quadratic duplicate check in MultiBuilder's Build method MultiBuilder needs to check for duplicate context kinds when building a multi-context. The previous behavior was O(N^2), which can be improved to O(N) since the list of contexts is sorted by kind. * re-add lduser.User as an alias for ldcontext.Context * disallow empty attribute name * misc doc comment formatting fixes (#98) * misc doc comment formatting fixes * indents * add online doc links * add readme note * Fix handling of both privateAttributes and redactedAttributes being present in easyJSON unmarshaller (#101) --------- Co-authored-by: Eli Bishop <[email protected]> Co-authored-by: LaunchDarklyCI <[email protected]> Co-authored-by: Ben Woskow <[email protected]> Co-authored-by: Sam Stokes <[email protected]> Co-authored-by: LaunchDarklyReleaseBot <[email protected]> Co-authored-by: Ember Stevens <[email protected]> Co-authored-by: ember-stevens <[email protected]> Co-authored-by: Casey Waldren <[email protected]> Co-authored-by: Matthew Wagner <[email protected]>
1 parent 7d0e56b commit dcd997e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

ldcontext/context_easyjson.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,10 @@ func unmarshalSingleKindEasyJSON(c *Context, in *jlexer.Lexer, knownKind Kind, u
169169
for !in.IsDelim('}') {
170170
key := in.UnsafeBytes() // see comment above
171171
in.WantColon()
172-
switch string(key) {
173-
case jsonPropPrivate:
174-
if usingEventFormat {
175-
in.SkipRecursive()
176-
continue
177-
}
172+
switch {
173+
case string(key) == jsonPropPrivate && !usingEventFormat:
178174
readPrivateAttributesEasyJSON(in, c, false)
179-
case jsonPropRedacted:
180-
if !usingEventFormat {
181-
in.SkipRecursive()
182-
continue
183-
}
175+
case string(key) == jsonPropRedacted && usingEventFormat:
184176
readPrivateAttributesEasyJSON(in, c, false)
185177
default:
186178
// Unrecognized property names within _meta are ignored. Calling SkipRecursive makes the Lexer

ldcontext/context_unmarshaling_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ func makeContextUnmarshalUnimportantVariantsParams() []contextSerializationParam
5252
// redactedAttributes is only a thing in the event output format, not the regular format
5353
{NewBuilder("my-key").Build(),
5454
`{"kind": "user", "key": "my-key", "_meta": {"redactedAttributes": ["name"]}}`},
55+
56+
// redactedAttributes and privateAttributes should not break deserialization
57+
// These test cases were added due to an issue where having both would break deserialization depending on which came first.
58+
{NewBuilder("my-key").Private("name").Build(),
59+
`{"kind": "user", "key": "my-key", "_meta": {"privateAttributes": ["name"], "redactedAttributes": ["name"]}}`},
60+
{NewBuilder("my-key").Private("name").Build(),
61+
`{"kind": "user", "key": "my-key", "_meta": {"redactedAttributes": ["name"], "privateAttributes": ["name"]}}`},
5562
}
5663
}
5764

0 commit comments

Comments
 (0)