gofeatureflag-python-provider 0.4.1__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gofeatureflag-python-provider
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: GO Feature Flag provider for OpenFeature
5
5
  License: Apache-2.0
6
6
  Keywords: feature flags,feature toggles,go-feature-flag,gofeatureflag,openfeature,open-feature
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Requires-Dist: asyncio (>=3.4.3,<4.0.0)
19
- Requires-Dist: openfeature-sdk (>=0.5.0,<0.8.0)
19
+ Requires-Dist: openfeature-sdk (>=0.5.0,<0.9.0)
20
20
  Requires-Dist: pydantic (>=2.5.2,<3.0.0)
21
21
  Requires-Dist: pylru (>=1.2.1,<2.0.0)
22
22
  Requires-Dist: rel (>=0.4.9,<0.5.0)
@@ -19,6 +19,7 @@ from openfeature.exception import (
19
19
  ErrorCode,
20
20
  FlagNotFoundError,
21
21
  GeneralError,
22
+ InvalidContextError,
22
23
  OpenFeatureError,
23
24
  TypeMismatchError,
24
25
  )
@@ -210,16 +211,29 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "gofeatureflag-python-provider"
3
- version = "0.4.1"
3
+ version = "0.4.2"
4
4
  description = "GO Feature Flag provider for OpenFeature"
5
5
  license = "Apache-2.0"
6
6
  authors = [ "Thomas Poignant" ]
@@ -28,7 +28,7 @@ classifiers = [
28
28
 
29
29
  [tool.poetry.dependencies]
30
30
  python = "^3.9"
31
- openfeature-sdk = ">=0.5.0,<0.8.0"
31
+ openfeature-sdk = ">=0.5.0,<0.9.0"
32
32
  pydantic = "^2.5.2"
33
33
  urllib3 = "^2.1.0"
34
34
  pylru = "^1.2.1"