Skip to content

feat(client): add get/set_evaluation_context methods - #590

Closed
balgaly wants to merge 1 commit into
open-feature:mainfrom
balgaly:feat/client-set-evaluation-context
Closed

feat(client): add get/set_evaluation_context methods#590
balgaly wants to merge 1 commit into
open-feature:mainfrom
balgaly:feat/client-set-evaluation-context

Conversation

@balgaly

Copy link
Copy Markdown
Contributor

Summary

Closes#500

Adds set_evaluation_context() and get_evaluation_context() to OpenFeatureClient per the OpenFeature spec requirement 3.2.2.

The client-level context is already merged correctly during flag evaluation (global → transaction → client → per-call). These methods expose a public setter/getter so callers can update the context after construction — matching what the Go, Java, and .NET SDKs already provide.

Changes

  • openfeature/client.py: add get_evaluation_context() and set_evaluation_context() with type validation
  • tests/test_client.py: 4 new tests covering set/get, type error, and integration with flag evaluation

Tests

test_client_set_evaluation_context_updates_context
test_client_get_evaluation_context_returns_current_context
test_client_set_evaluation_context_invalid_type_raises
test_client_set_evaluation_context_is_used_in_flag_evaluation

Adds set_evaluation_context() and get_evaluation_context() to
OpenFeatureClient per the OpenFeature spec requirement 3.2.2.
The client-level context is already merged correctly during flag
evaluation (between global/transaction and per-call contexts).
These methods expose a public setter/getter so callers can update
the context after construction.
Closesopen-feature#500
@balgaly
balgaly requested review from a team as code ownersApril 14, 2026 20:33

@gemini-code-assistgemini-code-assistBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces get_evaluation_context and set_evaluation_context methods to the OpenFeatureClient class, allowing for client-level evaluation context management as per the OpenFeature specification. The implementation includes type validation for the evaluation context and is supported by new unit tests covering context updates, retrieval, error handling for invalid types, and integration in flag evaluation. I have no feedback to provide.

@balgaly

Copy link
Copy Markdown
ContributorAuthor

Picked up on @gruebel's note in #565 that the actual fix for #500 is the missing E2E tests, not the setter. Going to close this PR and open a new one targeting those tests instead.

@balgaly

Copy link
Copy Markdown
ContributorAuthor

Superseded by #593, which implements the E2E tests @gruebel requested instead of adding a new setter.

@balgalybalgaly closed this Apr 17, 2026
Sign up for freeto 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.

[FEATURE] client evaluation context support

1 participant

@balgaly