fix: Prevent panic when setting non-comparable named providers #286
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR
If we set non-comparable provider multiple times as a named provider, runtime error panic occurs.
reflect.DeepEqual()
is generally used for provider-to-provider comparisons, but in one place a simple!=
is used for comparison between providers.go-sdk/openfeature/event_executor.go
Line 347 in fb88c24
This PR prevents panic by replacing the
!=
comparison with DeepEqual.Related Issues
How to test
reproduce the problem
go.mod:
main.go:
run:
Verify the fix
go.mod:
module hoge go 1.23.0 require github.com/open-feature/go-sdk v1.13.0 require ( github.com/go-logr/logr v1.4.2 // indirect golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect ) +replace github.com/open-feature/go-sdk v1.13.0 => github.com/Arthur1/openfeature-go-sdk v0.0.0-20240924220603-27a4a711ba16
run: