Closed tupton closed 3 years ago
Hi @tupton,
Thank you for the sandbox environment to reproduce the issue. That was helpful. I can reproduce the issue with your provided sample. However, when I change the client-side ID to a different value, flags are returned correctly. This supports my theory that the problem is not due to an SDK bug but rather an environment-specific misconfiguration.
Did you by chance enable "Secure mode" for this environment? This could potentially explain the problem -- if LaunchDarkly was told to enable secure mode yet the SDK was not configured to secure requests. See this documentation for more details. Note that while the docs are for the JavaScript SDK, they apply to the React SDK, too; the React SDK is a wrapper around the JavaScript SDK.
@bwoskow-ld I really appreciate the quick response and investigation.
We do indeed have "Secure mode" on for this environment, although I'm unsure if that's intentional or not ā we are in the midst of adopting LaunchDarkly and this may have just been a case of misunderstanding the setting. Disabling that seems to fix the immediate issue of this bad request error. Of course, we'll probably want to enable secure mode according to the documentation you linked at some point, with the proper SDK configuration.
Again, thanks for the quick help! I'm not sure how possible it would be to provide more detail in that error message, or at least document that un-configured client SDKs may result in that error if "Secure mode" is enabled, but that would be useful. Are documentation PRs accepted? If so, would https://github.com/launchdarkly/LaunchDarkly-Docs/blob/master/src/content/topics/sdk/client-side/javascript/index.mdx be the right place to add such documentation?
Yes, documentation PRs are accepted and encouraged š Additionally I'll file an internal request to improve the error message when secure mode is enabled.
Is this a support request? This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here and clicking "submit a request", or by emailing support@launchdarkly.com.
Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.
Describe the bug
After installing
launchdarkly-react-client-sdk@2.21.0
and using thewithLDProvider
HOC, I'm seeing a consistent400 Bad Request
when fetching flag settings:In the console:
index.js:1 LD: [error] Error fetching flag settings: 400
Inspecting the bad request further, I see this request:
https://app.launchdarkly.com/sdk/evalx/5fcaaa98fbf53c09e6f87c7c/users/eyJrZXkiOiIzNTllYTI5Ny1kNDY3LTQ5YWItYjA4MS00NTg0MWFmMDg1MDgifQ
and this response:
{"code":"invalid_request","message":"invalid user data"}
I am just sending a uuid as the
key
property of theuser
, as described in the documentation, and that seems to be reflected in the request path param (minus the trailing==
for some reason.)This results in the object that's returned from
useFlags
to always be empty.It's worth noting that later requests to
https://events.launchdarkly.com/events/bulk/
ofkind: 'identify'
and the exact same user data are successful.To reproduce
https://codesandbox.io/s/nervous-tharp-lwu0q?file=/src/App.js is a code-sandbox that reproduces the issue, but it's just a very simple use of
withLDProvider
:Expected behavior
I expect a request to
https://app.launchdarkly.com/sdk/evalx/5fcaaa98fbf53c09e6f87c7c/users/eyJrZXkiOiIzNTllYTI5Ny1kNDY3LTQ5YWItYjA4MS00NTg0MWFmMDg1MDgifQ
return successfully and its response to contain the flag settings for this user.Logs
From the console:
SDK version
launchdarkly-react-client-sdk@2.21.0
Language version, developer tools
Javascript, React 17 (also reproduced with React 16.12)
OS/platform Mac OS 10.15, Google Chrome 87.0.4280.88
Additional context Add any other context about the problem here.