Skip to content

fix(openfeature): treat empty contexts literally (FFL-2837) - #1359

Merged
btthomas merged 3 commits into
blake.thomas/FFL-2837-PR1from
blake.thomas/FFL-2837-context-semantics
Aug 7, 2026
Merged

fix(openfeature): treat empty contexts literally (FFL-2837)#1359
btthomas merged 3 commits into
blake.thomas/FFL-2837-PR1from
blake.thomas/FFL-2837-context-semantics

Conversation

@btthomas

@btthomas btthomas commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

PR stack

  1. Plan: #1345
  2. Rules engine boundary: #1346
  3. Context semantics and precomputed-context helper <- you are here
  4. Dynamic rules evaluation: #1347
  5. Dynamic offline OpenFeature API: #1348

Summary

This PR makes an empty OpenFeature context a real evaluation context. It does not use an empty context as a request to restore the context in a precomputed configuration.

This PR also exports getPrecomputedContext(configuration). The function returns a detached copy of the context in a valid precomputed branch. It returns undefined when the configuration has no context-specific precomputed branch. The function does not change OpenFeature or provider state.

The provider now preserves the difference between a missing targeting key and an empty targeting key. The online provider behavior does not change.

Reason

OpenFeature gives a provider the effective context. It uses an empty object when the global context is unset or cleared. The provider cannot determine which OpenFeature operation produced that object.

The old implementation treated the empty object as an internal reset command. This behavior did not match the browser SDK. It also made setContext({}) and clearContext() restore private configuration state.

Applications can now use the public helper to set the matching context explicitly before provider registration. Applications do not need to inspect the configuration wire or parsed object.

User impact

  • A context-specific precomputed configuration requires a matching effective OpenFeature context.
  • setContext({}) uses the empty context.
  • clearContext(domain) uses the inherited global context.
  • A context-agnostic precomputed configuration still works with any context.
  • Context changes do not fetch configuration.

Upstream follow-up

  • After openfeature-js-client#353 is released in @datadog/flagging-core, replace the local helper with the upstream re-export.

Validation

  • OpenFeature package: 40 tests passed.
  • Core flags package: 101 tests passed.
  • OpenFeature and core source lint passed.
  • OpenFeature package build passed.
  • Core package build passed.

The example-app lint command could not start because the current dependency installation does not contain the jest/globals ESLint environment. The changed package source passed lint, and both package builds passed.

@btthomas
btthomas marked this pull request as ready for review August 7, 2026 00:50
@btthomas
btthomas requested review from a team as code owners August 7, 2026 00:50
@btthomas
btthomas requested review from dd-oleksii and pavlokhrebto and removed request for a team August 7, 2026 00:50
@btthomas
btthomas merged commit d866b0f into blake.thomas/FFL-2837-PR1 Aug 7, 2026
1 check was pending
@btthomas
btthomas deleted the blake.thomas/FFL-2837-context-semantics branch August 7, 2026 00:50
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.

1 participant