Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special flag evaluation endpoints don't support custom targeting attributes #155

Closed
seangatewood opened this issue Oct 7, 2021 · 2 comments

Comments

@seangatewood
Copy link

Is this a support request?
Probably not, as this concerns an ld-relay-specific feature

Describe the bug
According to this section of the docs, the ld-relay provides some special endpoints that allows you to evaluate all feature flags for a given user dict.

That's super awesome, and would really help us with an internal tool we are building! However, it seems that this does not work for custom targeting attributes?

image

set -eu

if [ "$#" -ne 3 ]; then
  echo "Usage: $0 <SDK key> <Proxy base url> <test flag>"
  exit
fi

SDK_KEY=$1
PROXY_URL=$2
TEST_FLAG=$3

getFlagValue(){
  if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <User dict>"
    exit
  fi
  local user_dict=$1
  curl -fs -X REPORT $PROXY_URL/sdk/eval/user -H "Authorization: $SDK_KEY" -H "Content-Type: application/json" -d "$user_dict" | jq ".\"$TEST_FLAG\""
}

printf "firstName A: "
getFlagValue '{"key": "a00ceb", "firstName": "A"}' # true

printf "firstName B: "
getFlagValue '{"key": "a00ceb", "firstName": "B"}' # false

printf "potato A: "
getFlagValue '{"key": "a00ceb", "potato": "A"}' # false --> expected True :-(

printf "potato B: "
getFlagValue '{"key": "a00ceb", "potato": "B"}' # false

To reproduce
See script above

Expected behavior
See script above --> expected targeting for potato to work the same as firstName

Logs
N/A

SDK version
I just tested this with image ld-relay:6.4.4

Language version, developer tools
curl 7.64.1

OS/platform
macOs Catalina 10.15.7

Additional context
We would like to use this endpoint to read feature flags in a language which isn't officially supported by LaunchDarkly. We use custom targeting attributes exclusively.

@eli-darkly
Copy link
Contributor

This is just a misunderstanding about how to send the user data. Custom attributes aren't set at the top level of the user JSON object, but within a "custom" property.

Wrong:

{
  "key": "a00ceb",
  "potato": "A",
  "someOtherCustomAttribute": "B"
}
{
  "key": "a00ceb",
  "custom": {
    "potato": "A",
    "someOtherCustomAttribute": "B"
  }
}

That's not specific to the Relay Proxy, it's universal across all LD software where users can be represented in JSON. See: https://docs.launchdarkly.com/home/users/attributes#setting-custom-user-attributes

@seangatewood
Copy link
Author

D'oh, you are correct 🤦‍♂️🙂 Confirmed the above script works if you change it:

...
printf "potato A: "
getFlagValue '{"key": "a00ceb", "custom": {"potato": "A"}}' # true

printf "potato B: "
getFlagValue '{"key": "a00ceb", "custom": {"potato": "B"}}' # false

Awesome, this will work then for our use case. 🎉

Thank you! 🙏

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

No branches or pull requests

2 participants