fix: Validate privateAttributes in OpenFeature context conversion - #1990
kinyoklion wants to merge 1 commit into
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
@cursor review |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk-common size report |
The JavaScript OpenFeature providers now validate the
privateAttributesevaluation context attribute instead of forwarding it unchecked.privateAttributesvalue which is not an array is dropped and an error is logged_metais only added to the converted context when at least one private attribute survivesRequirements
Related issues
None.
Describe the solution you've provided
translateContextassigned_meta.privateAttributeswith avalue as string[]cast, so an application which setprivateAttributesto a string (or to an array containing non-strings) produced a context whose private attribute list was not a list of strings. The behavior spec (OFP 2.4.4, 2.4.5, 2.4.5.1) requires the attribute to be dropped with an error in that case, which is what the Java, Python, Ruby and PHP providers already do.Dropping the bad value is the safer of the two options here, since a malformed private attribute list can otherwise be silently ignored further down and result in attributes being sent to LaunchDarkly which the application intended to keep private.
Describe alternatives you've considered
Coercing entries to strings was rejected: private attribute names are references into the context, so a coerced name would not match any attribute and would give a false sense of privacy.
Additional context
Found during the weekly OpenFeature provider audit. The
key/targetingKeyvalidation gap in the same function is handled in a separate PR.Link to Devin session: https://app.devin.ai/sessions/9f0be899af7842e0b6a7bfc6229084f6
Open in Devin Desktop: https://app.devin.ai/desktop/session/9f0be899af7842e0b6a7bfc6229084f6?variant=devin
Requested by: @kinyoklion