@@ -96,7 +96,7 @@ func (o *OptimizelyClient) IsFeatureEnabled(featureKey string, userContext entit
96
96
}
97
97
}()
98
98
99
- context , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
99
+ decisionContext , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
100
100
if err != nil {
101
101
logger .Error ("received an error while computing feature decision" , err )
102
102
return result , err
@@ -116,7 +116,7 @@ func (o *OptimizelyClient) IsFeatureEnabled(featureKey string, userContext entit
116
116
117
117
if featureDecision .Source == decision .FeatureTest {
118
118
// send impression event for feature tests
119
- impressionEvent := event .CreateImpressionUserEvent (context .ProjectConfig , featureDecision .Experiment , * featureDecision .Variation , userContext )
119
+ impressionEvent := event .CreateImpressionUserEvent (decisionContext .ProjectConfig , featureDecision .Experiment , * featureDecision .Variation , userContext )
120
120
o .EventProcessor .ProcessEvent (impressionEvent )
121
121
}
122
122
return result , err
@@ -214,12 +214,12 @@ func (o *OptimizelyClient) GetFeatureVariableString(featureKey, variableKey stri
214
214
// GetFeatureVariable returns feature as a string along with it's associated type
215
215
func (o * OptimizelyClient ) GetFeatureVariable (featureKey , variableKey string , userContext entities.UserContext ) (value string , valueType entities.VariableType , err error ) {
216
216
217
- context , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
217
+ decisionContext , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
218
218
if err != nil {
219
219
return "" , "" , err
220
220
}
221
221
222
- variable , err := context .ProjectConfig .GetVariableByKey (featureKey , variableKey )
222
+ variable , err := decisionContext .ProjectConfig .GetVariableByKey (featureKey , variableKey )
223
223
if err != nil {
224
224
return "" , "" , err
225
225
}
@@ -243,11 +243,16 @@ func (o *OptimizelyClient) GetAllFeatureVariables(featureKey string, userContext
243
243
return enabled , variableMap , err
244
244
}
245
245
246
- feature := decisionContext .Feature
247
246
if featureDecision .Variation != nil {
248
247
enabled = featureDecision .Variation .FeatureEnabled
249
248
}
250
249
250
+ feature := decisionContext .Feature
251
+ if feature == nil {
252
+ logger .Warning (fmt .Sprintf (`feature "%s" does not exist` , featureKey ))
253
+ return enabled , variableMap , nil
254
+ }
255
+
251
256
for _ , v := range feature .VariableMap {
252
257
variableMap [v .Key ] = v .DefaultValue
253
258
0 commit comments