fix: freeze ClientMetadata to satisfy spec req 4.2.2.1#273
fix: freeze ClientMetadata to satisfy spec req 4.2.2.1#273cristiangmarta wants to merge 1 commit intoopen-feature:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Ensures client_metadata exposed by OpenFeature::SDK::Client is immutable to satisfy OpenFeature spec requirement 4.2.2.1 and prevent hooks from mutating shared client metadata across evaluations.
Changes:
- Freeze
ClientMetadatawhen constructing aClient. - Add a spec asserting
client.metadatais frozen.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spec/open_feature/sdk/client_spec.rb | Adds coverage asserting client metadata immutability via be_frozen. |
| lib/open_feature/sdk/client.rb | Freezes the ClientMetadata instance at client initialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request implements immutability for client metadata by freezing the ClientMetadata object during initialization and adding a corresponding test case. The review feedback points out that while the metadata object itself is frozen, the underlying domain string remains mutable, which could violate the immutability requirements. It is recommended to freeze the domain string as well and update the test suite to verify this deeper level of immutability.
Signed-off-by: Cristian Marta <cristian@caffe-lento.com>
5d9886c to
f13a181
Compare
Spec requirement 4.2.2.1 states that
client_metadatainHookContextMUST be immutable.ClientMetadatawas an unfrozen Struct — any hook could mutate it, corrupting the client's@metadatafor all subsequent evaluations since the same object is shared across hook invocations.Adds
.freezeat construction, consistent with how both built-in providers already handleProviderMetadata.