Skip to content

Conversation

pranjal-jately-ld
Copy link
Contributor

@pranjal-jately-ld pranjal-jately-ld commented Aug 30, 2025

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Describe the solution you've provided

This PR adds debug override capability to the LaunchDarkly SDK, allowing developers to override flag values during local development and testing without affecting production flag configurations.

Key features:

  • Flag Override Interface: New LDDebugOverride interface with methods to set, remove, and manage flag overrides.
  • Plugin Integration: Extended LDPlugin interface with optional registerDebug method for plugins to access override functionality.
  • Runtime Override Management: Override values take precedence over remote flag values while preserving original flag evaluation logic.
  • Testing: Added test coverage for all override methods and edge cases.

Additional context

This feature is designed primarily for development and testing workflows where developers need to:

  • Test different flag variations without modifying remote configurations.
  • Debug applications with specific flag states.
  • Validate feature behavior across different flag combinations.

The implementation maintains backward compatibility and follows the existing plugin architecture patterns. Override functionality is only available when explicitly enabled through plugins, ensuring it doesn't impact production performance or security.

pranjal-jately-ld and others added 10 commits August 19, 2025 13:02
This update introduces a new interface for plugins to register debug
capabilities, allowing for temporary flag value overrides during
local development.
…options

This update adds two new methods, `removeOverride` and `clearAllOverrides`,
to the debug override capabilities, allowing for more flexible management of
flag value overrides during local development. It also improves the
`setOverride` method to prevent race condition by checking if the same
value is already set.
This update introduces the `getAllOverrides` method to retrieve all
currently active flag overrides. It also refines the handling of flag
overrides in the `setOverride`, `removeOverride`, and `clearAllOverrides`
methods, ensuring that the current effective values are accurately managed.
Ensures consistent property validation.
Includes expanding plugin tests to check for
registration with debug override capabilities.
@pranjal-jately-ld pranjal-jately-ld force-pushed the add-flag-override-capability branch 4 times, most recently from bb2324f to 6a44cc5 Compare August 31, 2025 21:49
@pranjal-jately-ld pranjal-jately-ld force-pushed the add-flag-override-capability branch from 6a44cc5 to ce4a44f Compare August 31, 2025 21:59
@pranjal-jately-ld pranjal-jately-ld force-pushed the add-flag-override-capability branch from 02d876b to c40f020 Compare September 1, 2025 12:45
@pranjal-jately-ld pranjal-jately-ld marked this pull request as ready for review September 1, 2025 12:49
@pranjal-jately-ld pranjal-jately-ld requested a review from a team as a code owner September 1, 2025 12:49
src/index.js Outdated
const flagStore = {
get(key) {
// Check overrides first, then real flags
if (flagOverrides && utils.objectHasOwnProperty(flagOverrides, key) && flagOverrides[key]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to be able to override a flag to appear deleted? Versus just setting the value. It seems useful to be able to force an evaluation to use the default by masking out the real flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kinyoklion Interesting thought 🤔 In that case, do you see the API for overrides working something like setOverride("flag", { deleted: true }) and setOverride("flag", { value: true })? And are there any other flag properties that you think might be useful to override?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most other properties would not influence the application in the same way that a deleted flag would. Maybe this is something we can defer for now and just let overrides be set.

Initialize flagOverrides as undefined until needed, optimize getAll()
iteration, and simplify setOverride() logic.
Improves performance for common case where no overrides are used while
maintaining full compatibility.
@pranjal-jately-ld pranjal-jately-ld force-pushed the add-flag-override-capability branch 2 times, most recently from b8f581e to 11f992a Compare September 3, 2025 16:52
Introduced a new FlagStore module to encapsulate flag management logic.
@pranjal-jately-ld pranjal-jately-ld force-pushed the add-flag-override-capability branch from 11f992a to 40a34b9 Compare September 3, 2025 17:03
Copy link
Member

@kinyoklion kinyoklion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think things are looking pretty good. I added some minor comments and I have two overall comments.

I think we maybe want to be able to experiment with this interface. So I would add a comment to registerDebug to indicate that it is experimental, and for use by LaunchDarkly tools at this time.

I would also update the title of the PR, which will become a release note.

feat: Add experimental debug override functionality.

I would also like if you could add your updates to the plugin interface to our specification: https://github.com/launchdarkly/sdk-specs/tree/main/specs/PLUGIN-sdk-plugin-support

I think we could tag this as being client-side only for the time being.

@pranjal-jately-ld pranjal-jately-ld changed the title feat: add debug override functionality for plugins feat: Add experimental debug override functionality. Sep 4, 2025
Added experimental annotations to LDPlugin and LDDebugOverride
interfaces in typings.d.ts.
Add JSDoc comments to all FlagStore functions
@pranjal-jately-ld pranjal-jately-ld merged commit 8b2f757 into launchdarkly:main Sep 5, 2025
3 checks passed
pranjal-jately-ld pushed a commit that referenced this pull request Sep 8, 2025
🤖 I have created a release *beep* *boop*
---


##
[5.8.0](5.7.1...5.8.0)
(2025-09-05)


### Features

* Add experimental debug override functionality.
([#132](#132))
([8b2f757](8b2f757))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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