Skip to content

fix: Handle attribute names that look like attribute references - #2247

Merged
keelerm84 merged 1 commit into
mainfrom
mk/SDK-3754/escaped-attribute-references
Nov 25, 2026
Merged

keelerm84 merged 1 commit into
mainfrom
mk/SDK-3754/escaped-attribute-references

Conversation

@keelerm84

@keelerm84 keelerm84 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

SDK-3754. The failures were found by the new sdk-test-harness tests from SDK-3741.

Describe the solution you've provided

Every js-core SDK mishandled private attribute names that look like attribute references, such as /a, /b/c and /~x.

  • AttributeReference's unescape checked ref.indexOf('~') for truthiness. A component that begins with ~ returns index 0, so it was never unescaped. /~1a resolved to a literal ~1a attribute, and attributes named by escaped references in _meta.privateAttributes were not redacted from events. The check is now includes('~').
  • When a legacy user was converted to a context, privateAttributeNames were copied into _meta.privateAttributes unchanged. The context sent in client stream and poll requests then read those literal names as references. They are now escaped as literal references (/a becomes /~1a, /~x becomes /~1~0x), as Go's ldcontext does with NewLiteralRef. Names that don't start with / are unchanged.

redactedAttributes carries the reference string (/~1a), as go-sdk-events does.

The Browser, React and Vue contract-test suppressions for the new native-EventSource REPORT case are in a separate PR, so this fix doesn't add changelog entries to those packages.

Testing

The new unit tests in shared/common failed before the fix. I ran the harness branches containing the new tests (v2 and v3) with -run 'events/.*/look like references' -run '.*/requests/.*/look like references' and each package's CI suppression file:

SDK Harness Before the fix With the fix
server-node v2 4 fail (debug, identify, both index events) pass
server-node v3 not run pass
Node client (mobile key) v2 7 fail (3 events, stream and poll GET/REPORT) pass
Node client (mobile key) v3 not run pass
Node client (client-side ID) v2/v3 not run pass

Describe alternatives you've considered

None.

Additional context

One existing test expectation changed on purpose. A legacy private attribute name /a/b/c now serializes as /~1a~1b~1c.


Note

Overview
Fixes mishandling of private attribute names that look like attribute references (e.g. /a, /b/c, /~x) in shared context handling.

In AttributeReference, unescape now uses includes('~') instead of indexOf('~'), so path components that start with an escape sequence (like /~1a) are unescaped correctly and resolve to literal attribute keys rather than wrong nested paths.

When legacy users are converted to single-kind contexts, privateAttributeNames are no longer copied verbatim into _meta.privateAttributes. They are normalized through AttributeReference(name, true).redactionName, escaping leading / names (e.g. /a → /~1a) so they stay literal names and redact correctly in events and filtering without clobbering similarly named nested fields.

Reviewed by Cursor Bugbot for commit 7071608. Bugbot is set up for automated code reviews on this repo. Configure here.

AttributeReference skipped unescaping any component that began with `~`,
because it tested `indexOf('~')` for truthiness. References such as
`/~1a` resolved to the literal `~1a`, so private attributes named `/a`,
`/b/c` or `/~x` were never redacted from events.

Legacy users copied `privateAttributeNames` into `_meta.privateAttributes`
unchanged. The converted context sent in client flag requests then read
those literal names as references. They are now escaped as literal
references, as Go's ldcontext does.

SDK-3754
@keelerm84
keelerm84 requested a review from a team as a code owner November 24, 2026 21:44
@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 19254 bytes
Compressed size limit: 33000
Uncompressed size: 106414 bytes

@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 26507 bytes
Compressed size limit: 44000
Uncompressed size: 172426 bytes

@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 34681 bytes
Compressed size limit: 35500
Uncompressed size: 123799 bytes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium. Not approved because this exceeds the low-risk threshold: it changes private-attribute reference escaping and event redaction in shared common. SDK rules 1–3: not a release PR, allowed author, no workflow changes. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@keelerm84
keelerm84 merged commit 3eb6ca2 into main Nov 25, 2026
73 of 74 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3754/escaped-attribute-references branch November 25, 2026 13:30
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants