Skip to content

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

Merged
kinyoklion merged 1 commit into
mainfrom
devin/1787562204-sdk-key-guard
Sep 16, 2026
Merged

kinyoklion merged 1 commit into
mainfrom
devin/1787562204-sdk-key-guard

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 24, 2026 •

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


Note

Overview
Fixes the example app so a missing LaunchDarkly SDK key is caught before SDK init instead of failing with an authentication error.

The default sdkKey fallback changes from 'your-sdk-key' to an empty string so if (!sdkKey) runs when LAUNCHDARKLY_SDK_KEY is unset. The exit message now points users at LAUNCHDARKLY_SDK_KEY (as in the README) and still mentions editing index.js, and the process exits with code 1 in that case.

Reviewed by Cursor Bugbot for commit fa150d6. Bugbot is set up for automated code reviews on this repo. Configure here.

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

@kinyoklion
kinyoklion marked this pull request as ready for review September 15, 2026 21:47
@kinyoklion
kinyoklion requested a review from a team as a code owner September 15, 2026 21:47
@kinyoklion
kinyoklion requested a review from joker23 September 15, 2026 22:26
@kinyoklion
kinyoklion merged commit 82c0e60 into main Sep 16, 2026
7 checks passed
@kinyoklion
kinyoklion deleted the devin/1787562204-sdk-key-guard branch September 16, 2026 17:47
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.

2 participants