Skip to content

fix: restore environment variable fallback for API key#43

Open
Rayhan1967 wants to merge 1 commit intolaunchdarkly:mainfrom
Rayhan1967:fix/api-key-fallback
Open

fix: restore environment variable fallback for API key#43
Rayhan1967 wants to merge 1 commit intolaunchdarkly:mainfrom
Rayhan1967:fix/api-key-fallback

Conversation

@Rayhan1967
Copy link

@Rayhan1967 Rayhan1967 commented Feb 22, 2026

Description

This PR resolves an issue where the LAUNCHDARKLY_API_KEY environment variable fallback was ignored when the --api-key CLI flag was not provided.

Problem

The root cause was that the CLI implementation defaulted the apiKey to an empty string ("") when the flag was missing. Because the security module uses the nullish coalescing operator (??) to handle fallbacks, the empty string was treated as a defined value, preventing the intended fallback to the environment variable.

Solution

The default value for apiKey in the CLI start implementation has been changed from "" to undefined. This allows the nullish coalescing logic to correctly fall back to the LAUNCHDARKLY_API_KEY environment variable when the CLI flag is omitted.

Verification

Logic was verified by demonstrating that undefined allows the ?? operator to proceed to the fallback value, whereas "" does not.

This change improves support for MCP clients and automated environments that rely on environment variables for configuration.

#42

@Rayhan1967 Rayhan1967 changed the title fix(cli): default apiKey to undefined for environment variable fallback fix: restore environment variable fallback for API key Feb 22, 2026
@nieblara
Copy link
Contributor

Hey @Rayhan1967 , this is a change to a generated file, so it won't stick. but i've raised this with the SDK team for the codegen to see if they can get this fix in!

@nieblara
Copy link
Contributor

@Rayhan1967 Actually, just heard back from the team, we'll have this fixed up soon!

@joyrexus
Copy link

joyrexus commented Mar 4, 2026

can this be merged in as a provisional fix until the permanent codegen fix is in place?

it's been open 10 days and without the fix any mcp configs that rely on the env var interpolation are busted.

@joyrexus
Copy link

joyrexus commented Mar 6, 2026

"we'll have this fixed up soon!"

@nieblara this still gonna be fixed up soonish? just wondering when to check back.

@joyrexus
Copy link

joyrexus commented Mar 9, 2026

@nieblara can you please merge this or get it escalated to someone who can? thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants