Skip to content

Providing nil for the SDK key results in a cryptic error message #154

@alecgorge

Description

@alecgorge

Describe the bug
Providing nil for the SDK key results in a cryptic error message

# assuming i forgot to add LAUNCHDARKLY_SDK_KEY to the environments configuration
ld_client = LaunchDarkly::LDClient.new(ENV['LAUNCHDARKLY_SDK_KEY'])
Uncaught exception: undefined method `[]' for nil:NilClass
	.../gems/launchdarkly-server-sdk-5.7.2/lib/ldclient-rb/impl/diagnostic_events.rb:12:in `create_diagnostic_id'
	.../gems/launchdarkly-server-sdk-5.7.2/lib/ldclient-rb/ldclient.rb:51:in `initialize'

To reproduce
see above

Expected behavior
An error is thrown that an SDK key was not provided or was provided in an invalid format. I noticed this because in 1 of our 4 environments I misspelled the environment variable name somehow when setting up the configuration.

This was also a confusing error for developers who pulled the changes after the PR was merged adding LaunchDarkly but had forgotten to update their development env using our dev setup script.

Logs
see above

SDK version
launchdarkly-server-sdk (5.7.2)

Language version, developer tools
Ruby

OS/platform
macOS 10.15.4

Additional context
no

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions