@@ -72,7 +72,7 @@ func processConfigUpdate(provider *DatadogProvider, path string, data []byte) rc
7272 // Parse the configuration
7373 log .Debug ("openfeature: remote config: processing configuration update %q: %s" , path , string (data ))
7474
75- var config serverConfiguration
75+ var config universalFlagsConfiguration
7676 if err := json .Unmarshal (data , & config ); err != nil {
7777 log .Error ("openfeature: remote config: failed to unmarshal configuration %q: %v" , path , err .Error ())
7878 return rc.ApplyStatus {
@@ -82,7 +82,7 @@ func processConfigUpdate(provider *DatadogProvider, path string, data []byte) rc
8282 }
8383
8484 // Validate the configuration
85- err := validateConfiguration (& config . FlagConfiguration )
85+ err := validateConfiguration (& config )
8686 if err != nil {
8787 log .Error ("openfeature: remote config: invalid configuration %q: %v" , path , err .Error ())
8888 return rc.ApplyStatus {
@@ -92,8 +92,8 @@ func processConfigUpdate(provider *DatadogProvider, path string, data []byte) rc
9292 }
9393
9494 // Update the provider with the new configuration
95- provider .updateConfiguration (& config . FlagConfiguration )
96- log .Debug ("openfeature: remote config: successfully applied configuration %q with %d flags" , path , len (config .FlagConfiguration . Flags ))
95+ provider .updateConfiguration (& config )
96+ log .Debug ("openfeature: remote config: successfully applied configuration %q with %d flags" , path , len (config .Flags ))
9797
9898 return rc.ApplyStatus {
9999 State : rc .ApplyStateAcknowledged ,
@@ -102,13 +102,11 @@ func processConfigUpdate(provider *DatadogProvider, path string, data []byte) rc
102102
103103// validateConfiguration performs basic validation on a serverConfiguration.
104104func validateConfiguration (config * universalFlagsConfiguration ) error {
105- if config == nil {
106- return fmt .Errorf ("configuration is nil" )
105+ if config . Format != "SERVER" {
106+ return fmt .Errorf ("unsupported format %q, expected SERVER (Is the remote config payload the right format ?)" , config . Format )
107107 }
108108
109- if config .Format != "SERVER" && config .Format != "" {
110- return fmt .Errorf ("unsupported format %q, expected SERVER" , config .Format )
111- }
109+ hasFlags := len (config .Flags ) > 0
112110
113111 // Validate each flag and delete invalid ones from the map
114112 // Collect errors for reporting
@@ -119,6 +117,10 @@ func validateConfiguration(config *universalFlagsConfiguration) error {
119117 return err != nil
120118 })
121119
120+ if hasFlags && len (config .Flags ) == 0 {
121+ errs = append (errs , errors .New ("all flags are invalid" ))
122+ }
123+
122124 return errors .Join (errs ... )
123125}
124126
0 commit comments