Skip to content

fix: restore the missing-SDK-key guard in index.js - #22

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

fix: restore the missing-SDK-key guard in index.js#22
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787562204-sdk-key-guard

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Routine SDK audit of this example; no version change was needed, but the "please set your SDK key" guard was dead code.

  • @launchdarkly/node-server-sdk needs no bump: manifest declares ^9.12.1, latest on npm is 9.13.1, and there is no committed lock file, so npm install already resolves to latest 9.x.
  • Fixed the unreachable guard — the placeholder default made if (!sdkKey) always false:
-const sdkKey = process.env.LAUNCHDARKLY_SDK_KEY ?? 'your-sdk-key';
+const sdkKey = process.env.LAUNCHDARKLY_SDK_KEY ?? '';
  • Guard message now names the env var the README tells users to set, instead of pointing at index.js only.
  • Titled fix: (not chore:) because it touches shipped example code.
  • No deprecated APIs: init, waitForInitialization({timeout}), variation, on('update:...') are all current; no deprecation warnings under node --trace-deprecation.
Implementation details

Before this change, running node index.js without LAUNCHDARKLY_SDK_KEY initialized the SDK with the literal string your-sdk-key and failed with an opaque error, and exited 0 in the CI path:

error: [LaunchDarkly] Authentication failed. Double check your SDK key.
*** SDK failed to initialize: Error: Authentication failed. Double check your SDK key.

After:

$ node index.js
*** Please set LAUNCHDARKLY_SDK_KEY to your LaunchDarkly SDK key, or edit index.js to set sdkKey.
(exit 1)

Validation with a real key (hello-apps project, flag hello-boolean):

$ npm install                # installs @launchdarkly/node-server-sdk 9.13.1, 0 vulnerabilities
$ CI=1 LAUNCHDARKLY_SDK_KEY=<sdk key> LAUNCHDARKLY_FLAG_KEY=hello-boolean node index.js
info: [LaunchDarkly] Opened LaunchDarkly stream connection
*** SDK successfully initialized!
*** The 'hello-boolean' feature flag evaluates to true.
<banner>

README needed no change: it already documents LAUNCHDARKLY_SDK_KEY / LAUNCHDARKLY_FLAG_KEY and mentions no SDK version. Console app, so no screenshots. Diff is 2 insertions / 2 deletions.

Link to Devin session: https://app.devin.ai/sessions/3b513691f831464c8b12d98f09d0387f

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 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 Created by Devin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants