[flagd-in-process] Add targeting validation and log warning
The Go/in-process, Java/in-process and standalone versions of flagd log a warning message with invalid targeting rules when they are fetched. We should implement this in the JS/in-process.
Targeting rules can be validated with the flags.json schema in conjunction with the targeting.json schema. Both will have to be loaded into AJV to fully validate. See similar examples in Go and Java
The in-process provider should be modified to use both of these schemas, and validate against them, only logging a warning if validation fails. Only a failure to parse the definition into a FeatureFlag instance should cause an abortive error (this means relaxing the existing validation to be consistent with all other impls which just do basic parsing).
Fully agree on this improvement. For example in our go provider, we use flag's core modules which also follow this approach [1]. So this definitely helps us with the consistency.
[1] - https://github.com/open-feature/flagd/blob/core/v0.8.0/core/pkg/evaluator/json.go#L428-L435
I am not sure if I understand this task correctly, but https://github.com/open-feature/js-sdk-contrib/blob/main/libs/shared/flagd-core/src/lib/parser.ts#L8 seems to me we're already doing validation, and only throw an exception if the property is set, else it is a warning.
Did I miss something here, @toddbaert? or should we do something differently?
specifically due to https://github.com/open-feature/js-sdk-contrib/pull/878 - funny how the numbers are just twisted between pr and issue ;)
You are right. I or somebody else must have done this!