Skip to content

Conversation

@leakonvalinka
Copy link
Member

Fixing the inconsistencies regarding error codes for edge cases, as described in #1679

leakonvalinka and others added 2 commits July 21, 2025 11:14
Fixing the inconsistencies regarding error codes for edge cases, as described in #1679

Signed-off-by: Konvalinka <[email protected]>
@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.20%. Comparing base (abd39e4) to head (327112e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ure/contrib/provider/flagd/resolvers/in_process.py 91.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
- Coverage   94.21%   94.20%   -0.02%     
==========================================
  Files          20       20              
  Lines        1020     1035      +15     
==========================================
+ Hits          961      975      +14     
- Misses         59       60       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

aepfli and others added 6 commits July 21, 2025 12:44
Signed-off-by: Simon Schrottner <[email protected]>
Signed-off-by: Simon Schrottner <[email protected]>

diff --git c/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/in_process.py i/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/in_process.py
index 3906a2e..50565c6 100644
--- c/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/in_process.py
+++ i/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/in_process.py
@@ -147,8 +147,8 @@ class InProcessResolver:
                     flag_metadata=metadata,
                     reason=Reason.DEFAULT,
                 )
-            if isinstance(variant, bool):
-                variant = str(variant).lower()
+
+            variant = str(variant).lower() # convert to string to support shorthand
             if variant not in flag.variants:
                 raise GeneralError(
                     f"Resolved variant {variant} not in variants config."
Signed-off-by: Simon Schrottner <[email protected]>
…wise

Signed-off-by: Simon Schrottner <[email protected]>
Co-authored-by: Lea Konvalinka <[email protected]>
…wise

Signed-off-by: Simon Schrottner <[email protected]>
Co-authored-by: Lea Konvalinka <[email protected]>

diff --git c/providers/openfeature-provider-flagd/tests/e2e/step/context_steps.py i/providers/openfeature-provider-flagd/tests/e2e/step/context_steps.py
index 3d3b502..539e71e 100644
--- c/providers/openfeature-provider-flagd/tests/e2e/step/context_steps.py
+++ i/providers/openfeature-provider-flagd/tests/e2e/step/context_steps.py
@@ -48,6 +48,18 @@ def update_context_without_value(

+@given(
+    parsers.cfparse(
+        'a context containing a key "{key}", with type "{type_info}" and with value ""'
+    ),
+)
+def update_context_without_value(
+    evaluation_context: EvaluationContext, key: str, type_info: str
+):
+    """a context containing a key and value."""
+    update_context(evaluation_context, key, type_info, "")
+
+
 @when(
     parsers.cfparse(
         'context contains keys {fields:s} with values "{svalue}", "{svalue2}", {ivalue:d}, "{bvalue:bool}"',
Signed-off-by: Simon Schrottner <[email protected]>
@aepfli aepfli marked this pull request as ready for review July 21, 2025 12:12
@aepfli aepfli requested review from a team as code owners July 21, 2025 12:12
aepfli added 5 commits July 21, 2025 14:21
Signed-off-by: Simon Schrottner <[email protected]>
Signed-off-by: Simon Schrottner <[email protected]>
Signed-off-by: Simon Schrottner <[email protected]>
Signed-off-by: Simon Schrottner <[email protected]>
Signed-off-by: Simon Schrottner <[email protected]>
Copy link
Member

@gruebel gruebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good 🍻

@aepfli aepfli merged commit 64d755b into open-feature:main Jul 22, 2025
26 of 27 checks passed
value,
variant=variant,
reason=Reason.ERROR,
error_code=ErrorCode.FLAG_NOT_FOUND,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I compared this to the other methods, and there is a special error message used ""Flag '" + key+ "' has no default variant defined, will use code default"" maybe we should adapt the tests to add the message to be in sync in all of them? wdyt? @leakonvalinka

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it definitely wouldn't hurt
however i dont know if the error messages are actually used for anything except logs? if not, i think this doesn't have a high priority then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants