@@ -96,7 +96,7 @@ func (o *OptimizelyClient) IsFeatureEnabled(featureKey string, userContext entit
9696 }
9797 }()
9898
99- context , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
99+ decisionContext , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
100100 if err != nil {
101101 logger .Error ("received an error while computing feature decision" , err )
102102 return result , err
@@ -116,7 +116,7 @@ func (o *OptimizelyClient) IsFeatureEnabled(featureKey string, userContext entit
116116
117117 if featureDecision .Source == decision .FeatureTest {
118118 // 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 )
120120 o .EventProcessor .ProcessEvent (impressionEvent )
121121 }
122122 return result , err
@@ -214,12 +214,12 @@ func (o *OptimizelyClient) GetFeatureVariableString(featureKey, variableKey stri
214214// GetFeatureVariable returns feature as a string along with it's associated type
215215func (o * OptimizelyClient ) GetFeatureVariable (featureKey , variableKey string , userContext entities.UserContext ) (value string , valueType entities.VariableType , err error ) {
216216
217- context , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
217+ decisionContext , featureDecision , err := o .getFeatureDecision (featureKey , userContext )
218218 if err != nil {
219219 return "" , "" , err
220220 }
221221
222- variable , err := context .ProjectConfig .GetVariableByKey (featureKey , variableKey )
222+ variable , err := decisionContext .ProjectConfig .GetVariableByKey (featureKey , variableKey )
223223 if err != nil {
224224 return "" , "" , err
225225 }
@@ -243,11 +243,16 @@ func (o *OptimizelyClient) GetAllFeatureVariables(featureKey string, userContext
243243 return enabled , variableMap , err
244244 }
245245
246- feature := decisionContext .Feature
247246 if featureDecision .Variation != nil {
248247 enabled = featureDecision .Variation .FeatureEnabled
249248 }
250249
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+
251256 for _ , v := range feature .VariableMap {
252257 variableMap [v .Key ] = v .DefaultValue
253258
0 commit comments