Repository navigation
fix: freeze ClientMetadata to satisfy spec req 4.2.2.1 - #273
cristiangmarta wants to merge 1 commit into
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
josecolella
left a comment
There was a problem hiding this comment.
Thanks, and sorry for the long wait. LGTM. This is part of the spec v0.9.0 push tracked in #300.
Under v0.9.0 numbering this fixes 1.2.2 and 4.2.2.2 (frozen client metadata). Nothing blocking, but the title still cites 4.2.2.1.
|
This now lives in #355, together with #270, #271 and #273. Your commit is cherry-picked unchanged and keeps your authorship, and the squash commit will credit you as co-author. CI couldn't run on this fork branch, and it had fallen behind |
|
Follow-up: this PR's title cited 4.2.2.1 (hook hints), which the frozen |
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.