File tree 1 file changed +16
-2
lines changed
openfeature/providers/python-provider/gofeatureflag_python_provider
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 19
19
ErrorCode ,
20
20
FlagNotFoundError ,
21
21
GeneralError ,
22
+ InvalidContextError ,
22
23
OpenFeatureError ,
23
24
TypeMismatchError ,
24
25
)
@@ -210,16 +211,29 @@ def generic_go_feature_flag_resolver(
210
211
body = goff_request .model_dump_json (),
211
212
)
212
213
214
+ response_body = response .data
215
+
216
+ # Handle 404 error code
213
217
if response .status == HTTPStatus .NOT_FOUND .value :
214
218
raise FlagNotFoundError (
215
219
"flag {} was not found in your configuration" .format (flag_key )
216
220
)
217
221
218
- if int (response .status ) >= HTTPStatus .BAD_REQUEST .value :
222
+ # Handle 400 error code
223
+ if int (response .status ) == HTTPStatus .BAD_REQUEST .value :
224
+ response_dict = json .loads (response_body )
225
+ error_message = response_dict .get ("message" )
226
+
227
+ if error_message is None :
228
+ error_message = "no error message given."
229
+
230
+ raise InvalidContextError ("Invalid context: " + error_message )
231
+
232
+ # Handle every error response above 400
233
+ if int (response .status ) > HTTPStatus .BAD_REQUEST .value :
219
234
raise GeneralError (
220
235
"impossible to contact GO Feature Flag relay proxy instance"
221
236
)
222
- response_body = response .data
223
237
224
238
response_flag_evaluation = ResponseFlagEvaluation .model_validate_json (
225
239
response_body
You can’t perform that action at this time.
0 commit comments