Repository navigation
feat!: Return private attributes as a Set - #476
Merged
Merged
Conversation
Config#private_attributes now returns a Set of attribute reference strings instead of an Array. The :private_attributes option still accepts any Enumerable, and the SDK converts it to a Set. LDContext#private_attributes now returns a frozen Set of Reference objects instead of an Array. The context already stored a Set internally and copied it to an Array on every call. Private attributes have no meaningful order or duplicates, so a Set is the correct type. Code that indexes into the result or calls Array-only methods on it must change. LDContext#to_h and #to_json still emit privateAttributes as an Array, so serialized contexts and event payloads do not change.
keelerm84
marked this pull request as ready for review
November 2, 2026 16:51
kinyoklion
approved these changes
Nov 2, 2026
Member
|
I think we need to freeze the private_attributes set on the config maybe. |
Member
|
I do have some concerns that you cannot access this property and then feed it directly back into a context without causing a problem. |
Config#private_attributes now returns a Set. Without the freeze, a caller can change the set after the client starts, and the event processor reads the changed set. LDContext#private_attributes is already frozen, so this makes the two match.
Config#private_attributes now returns a Set, but LDContext.create rejected any privateAttributes value that was not an Array. Passing the config value into a context made an invalid context. LDContext.create now accepts an Array or a Set.
LDContext#private_attributes returns a Set of Reference objects. Reference.create accepted only a String or a Symbol, so passing those references into a new context made each one an empty reference, and the SDK dropped them. Reference.create now returns a Reference argument unchanged. A Reference is immutable, so it is safe to share. This also lets Config accept references in private_attributes.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 228d01e. Configure here.
context_spec.rb loads only ldclient-rb/context, so the spec failed with NameError when the file ran alone. A Set literal tests the same path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Config#private_attributes now returns a Set of attribute reference
strings instead of an Array. The :private_attributes option still
accepts any Enumerable, and the SDK converts it to a Set.
LDContext#private_attributes now returns a frozen Set of Reference
objects instead of an Array. The context already stored a Set
internally and copied it to an Array on every call. Private attributes
have no meaningful order or duplicates, so a Set is the correct type.
Code that indexes into the result or calls Array-only methods on it
must change. LDContext#to_h and #to_json still emit privateAttributes
as an Array, so serialized contexts and event payloads do not change.
Note
Overview
Breaking change:
Config#private_attributesandLDContext#private_attributesnow expose frozenSets instead of arrays. The:private_attributesconfig option still accepts anyEnumerableand is normalized (deduped) into a set; context_meta.privateAttributesmay be an array or a set when building a context.LDContextstops copying its internal set to an array on every read, and equality checks use set comparison directly.ContextFilterstores global private refs in a set and merges them with context refs via set union (|).Reference.createis idempotent when passed an existingReference.Serialized context output is unchanged:
hash_single_kindstill emitsprivateAttributesas an array via.to_a.Reviewed by Cursor Bugbot for commit 4de0ad6. Bugbot is set up for automated code reviews on this repo. Configure here.