Skip to content

fix: start the LaunchDarkly client offline when LD_SDK_KEY is unset - #19

Draft
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1788167314-guard-missing-sdk-key
Draft

fix: start the LaunchDarkly client offline when LD_SDK_KEY is unset#19
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1788167314-guard-missing-sdk-key

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Running the example without LD_SDK_KEY crashed the whole application with a multi-thousand-line supervisor stack trace, because os:getenv/1 returns the atom false (not "") when the variable is unset and that atom was passed straight into ldclient:start_instance/2.

  • hello_erlang_server:init/1 now dispatches through start_ldclient/1, which starts the client with #{offline => true} and logs a warning when the key is missing or empty.
  • Evaluations then return their fallback value instead of the gen_server dying with noproc on the first hello_erlang_server:get/3 call.
  • No dependency changes: ldclient 3.11.2 is the latest release in the current major, and rebar3 upgrade --all reports every locked transitive dependency already at its latest resolvable version.
  • No deprecated SDK APIs and no deprecation warnings when compiling or running.
Implementation details
start_ldclient(SdkKey) when SdkKey =:= false; SdkKey =:= "" ->
  logger:warning("LD_SDK_KEY is not set; ..."),
  ldclient:start_instance("", #{offline => true});
start_ldclient(SdkKey) ->
  ldclient:start_instance(SdkKey, #{http_options => #{tls_options => ldclient_config:tls_basic_options()}}).

Skipping start_instance entirely was rejected: ldclient:variation/3 then exits, so the example would still fail on the first evaluation.

Testing (Erlang/OTP 27 via docker run erlang:27, rebar3 compile + rebar3 shell):

  • With a real server SDK key: streaming connection established, hello_erlang_server:get(<<"hello-boolean">>, false, <<"user-key-123abc">>) returned the flag value from LaunchDarkly.
  • With LD_SDK_KEY unset: warning logged, application boots, same call returns the false fallback (previously: crash).

Not a UI change, so no screenshots or staging link apply.

Link to Devin session: https://app.devin.ai/sessions/39c567ec09c14cb3973cb2f73337f733
Open in Devin Desktop: https://app.devin.ai/desktop/session/39c567ec09c14cb3973cb2f73337f733?variant=devin

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

@cursor review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants