From e109beb5e2231f9e4d7f9a70db831b84bb05f5ec Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Tue, 21 Jul 2026 13:53:16 -0400 Subject: [PATCH] fix: Pass private attribute raw paths to LDContext in contract tests 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. --- contract-tests/client_entity.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contract-tests/client_entity.rb b/contract-tests/client_entity.rb index 46194a16..5df1f56a 100644 --- a/contract-tests/client_entity.rb +++ b/contract-tests/client_entity.rb @@ -291,10 +291,14 @@ def close if params[:privateAttributes] context[:_meta] = { privateAttributes: params[:privateAttributes].map do |attribute| + # LDContext.create re-parses each _meta private attribute as a + # reference string, so hand it the raw path rather than a Reference + # object. For a literal name this is the escaped single-component + # form (e.g. "/address/street" -> "/~1address~1street"). if attribute[:literal] - LaunchDarkly::Reference.create_literal(attribute[:value]) + LaunchDarkly::Reference.create_literal(attribute[:value]).raw_path else - LaunchDarkly::Reference.create(attribute[:value]) + LaunchDarkly::Reference.create(attribute[:value]).raw_path end end, }