test: Pass private attribute raw paths to LDContext in contract tests#408
Merged
keelerm84 merged 1 commit intoJul 21, 2026
Merged
Conversation
The contextComparison handler built LaunchDarkly::Reference objects and placed them in _meta.privateAttributes, but LDContext.create re-parses each element as a reference string via Reference.create, which rejects non-strings. Every private attribute was therefore dropped, so context comparisons involving private attributes were never exercised. Pass the reference raw path (a string) instead. For a literal name this is the escaped single-component form, which LDContext.create re-parses into the correct reference.
keelerm84
marked this pull request as ready for review
July 21, 2026 17:57
jsonbailey
approved these changes
Jul 21, 2026
keelerm84
deleted the
mk/SDK-2738/fix-context-comparison-private-attributes
branch
July 21, 2026 19:38
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.
Summary
The
contextComparisonhandler in the contract test service builtLaunchDarkly::Referenceobjects and placed them in_meta.privateAttributes. ButLDContext.createre-parses each element of that array as a reference string viaReference.create, which rejects any non-String/Symbol input. Every private attribute was therefore silently dropped, and context comparisons involving private attributes were never exercised -- both contexts were always compared with empty private-attribute sets.The SDK's own
LDContextequality is correct (order-independent set of references; literal names compare equal to the equivalent reference). The defect was isolated to the contract test service.This passes the reference
raw_path(a string) toLDContext.createinstead of theReferenceobject. For a literal attribute name this is the escaped single-component form (e.g./address/street->/~1address~1street), whichLDContext.createre-parses into the correct reference.Verified locally by running the
context type/comparesuite from a local sdk-test-harness build against this service: all 16 comparison tests pass, including two negative cases where private attributes are the sole differentiator.Note on ordering
The failing behavior was previously masked by a bug in the released test harness (a malformed
privateAttributesJSON tag) that meant private attributes were never sent for thecontextComparisoncommand. That harness bug is fixed in launchdarkly/sdk-test-harness#391 (v2) and #392 (v3), which also add the negative tests that catch this. Until the harness fix is released, this SDK's contract-test CI (which downloads the released v2 harness) will not yet exercise the new cases.Note
Low Risk
Test-only change in the contract test service; no production SDK behavior is modified.
Overview
Fixes contract test
contextComparisonso_meta.privateAttributesis built the wayLDContext.createexpects.The harness was putting
LaunchDarkly::Referenceinstances intoprivateAttributes, butLDContext.createtreats each entry as a reference string and re-parses it. Non-string values were dropped, so comparisons never exercised private attributes. The builder now passes each reference’sraw_path(including escaped literal paths fromReference.create_literal) so contexts are created with the intended private-attribute set.Reviewed by Cursor Bugbot for commit e109beb. Bugbot is set up for automated code reviews on this repo. Configure here.