Skip to content

fix: guard against an unset LAUNCHDARKLY_SDK_KEY - #15

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

fix: guard against an unset LAUNCHDARKLY_SDK_KEY#15
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787562267-guard-unset-sdk-key

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

SDK audit of this example against the latest gems. No dependency changes were required; one real bug in main.rb is fixed.

  • main.rb never hit its own "please set the env var" branch: ENV['LAUNCHDARKLY_SDK_KEY'] is nil (not '') when unset, so the example crashed with a raw ArgumentError: sdk_key must not be nil stack trace from the SDK instead of the intended message.
    -if sdk_key == ''
    +if sdk_key.nil? || sdk_key.empty?
    -elsif feature_flag_key == ''
    +elsif feature_flag_key.empty?
  • feature_flag_key always has a default, so it can only be a string — its check is simplified to .empty?.
  • No version bumps: every Gemfile constraint already resolves to the latest release and no Gemfile.lock is committed (launchdarkly-server-sdk 8.15.0, launchdarkly-openfeature-server-sdk 0.2.0 under ~> 0.2, openfeature-sdk 0.6.5, listen 3.10.0 under ~> 3.3).
  • No deprecated LaunchDarkly or OpenFeature APIs in use; remaining -w warnings all originate inside third-party gems.
Implementation details

Validated in a ruby:3.4 container (matching CI's ruby-version: 3.4) with the latest gems installed from the uncommitted resolution:

$ LAUNCHDARKLY_SDK_KEY=*** LAUNCHDARKLY_FLAG_KEY=hello-boolean bundle exec ruby main.rb
*** The hello-boolean feature flag evaluates to true.

$ bundle exec ruby main.rb          # key unset
*** Please set the LAUNCHDARKLY_SDK_KEY environment variable
exit=1

Before the fix, the second invocation ended in ldclient.rb:74:in 'LaunchDarkly::LDClient#initialize': sdk_key must not be nil (ArgumentError).

RUBYOPT=-w warnings are all upstream and not fixable here: http-cookie circular require, openfeature-sdk circular require / flag_metadata method redefinition, and unused-variable warnings inside launchdarkly-server-sdk.

Ruby ≥ 3.4 is genuinely required (both launchdarkly-openfeature-server-sdk 0.2.0 and openfeature-sdk 0.6.5 declare required_ruby_version >= 3.4); documenting that in the README is already covered by the open PR #14, so it is not duplicated here.

fix: rather than chore: because the change touches shipped example code.

Link to Devin session: https://app.devin.ai/sessions/2d84367c077e4bc287c95457e9cd7422

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 devin-ai-integration Bot added the devin-pr PR created by Devin label Aug 24, 2026
@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

devin-pr PR created by Devin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants