Skip to content

Guard precomputed ETag reuse by context - #364

Open
leoromanovsky wants to merge 60 commits into
sameerank/FFL-2934/configuration-fetchers-bootstrap-initfrom
agent/guard-precomputed-etag-context
Open

Guard precomputed ETag reuse by context#364
leoromanovsky wants to merge 60 commits into
sameerank/FFL-2934/configuration-fetchers-bootstrap-initfrom
agent/guard-precomputed-etag-context

Conversation

@leoromanovsky

Copy link
Copy Markdown
Collaborator

Motivation

fetchPrecomputedConfiguration accepts a caller-supplied previous configuration. When that configuration belongs to context A but the new request targets context B, the public fetcher currently sends context A’s ETag and can reuse A’s assignments after a 304 Not Modified response.

This PR is stacked on #351 to demonstrate and close that context-boundary gap.

Changes

  • validate previousConfiguration against the requested context inside fetchPrecomputedConfiguration
  • use only the validated configuration when setting If-None-Match or handling 304
  • add a regression test that models context A returning 304 when its ETag is incorrectly sent, while context B returns fresh assignments when it is omitted

Decisions

The invariant lives in the exported public fetcher rather than only in createFlagsConfigurationFetcher, so direct callers receive the same context-safety guarantee as the provider wrapper. Rules configurations remain unchanged because they are not precomputed for an evaluation context.

Validation:

  • yarn workspace @datadog/openfeature-browser test --runInBand test/transport/fetchConfiguration.spec.ts — 25 tests passed
  • yarn workspace @datadog/openfeature-browser typecheck
  • yarn biome check packages/browser/src/transport/fetchConfiguration.ts packages/browser/test/transport/fetchConfiguration.spec.ts --diagnostic-level=error

@leoromanovsky
leoromanovsky marked this pull request as ready for review August 12, 2026 20:30
@leoromanovsky
leoromanovsky requested a review from a team as a code owner August 12, 2026 20:30
@leoromanovsky
leoromanovsky requested review from dd-oleksii, sameerank and typotter and removed request for a team and typotter August 12, 2026 20:30
Comment on lines +92 to +94
const previousConfiguration = configMatchesContext(options.previousConfiguration, options.context)
? options.previousConfiguration
: undefined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

major: reusing etag across context must be fine. If context change results in a different response, that response must have a different etag. If context changed in a way that does not affect the response, it should get the same etag (e.g. change in attribute that is not used for evaluation).

So having some etag is better than none. We also want to avoid busting cache on insignificant attribute change.

@sameerank
sameerank force-pushed the sameerank/FFL-2934/configuration-fetchers-bootstrap-init branch 3 times, most recently from 567a26c to fda2716 Compare August 18, 2026 15:21
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