-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(config-cat): Forward default value to underlying client #1214
Conversation
…re#1213) Signed-off-by: Adam Simon <[email protected]>
6a0a1bc
to
2e1d2cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me!
@adams85 please check the formatting and the linter errors which also seem only be related to imports and format.
You should also be able to fix it by running npm run lint -- --fix
from the root.
Signed-off-by: Adam Simon <[email protected]>
ec68854
to
8e22be7
Compare
Okay, it looks like the formatting issues are gone but some test cases are broken. Unfortunately, I don't have time for fixing them now, will look into that later. |
Great, thanks!
All the tests that test for a |
Thanks for the guidance. I made some progress and brought the number of failing tests down to 1. The only test case that fails now is "should throw TypeMismatchError if string is only a JSON primitive", and I'm a bit confused about that. Could you explain why The method signature of |
Signed-off-by: Adam Simon <[email protected]>
bb3732a
to
45564c4
Compare
You are right @adams85, I agree the test is wrong and we should follow the types allowed. |
Hmm, it might not be that simple after all... Let me explain. So again, this is the method signature that's defined by the resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext, logger: Logger): ResolutionDetails<T>; When we call this method like it's done in the problematic test case, we may run into problems: const result = provider.resolveObjectEvaluation('jsonPrimitive', {}, { targetingKey })); What's the inferred type of What guarantees that this method call always returns a In other words, this method signature seems to make a "false promise" currently. I can see two options to resolve this correctly:
Option 1 doesn't feel right. Why should this method require feature flag evaluation to return a value of exactly the same type as the default value. That wouldn't make much sense. Plus, as far as I can see, other providers don't do such checks either. Option 2 seems to be the correct approach but it would be a significant breaking change to a core interface... So, what's your opinion, what should we do here? Do you maybe have any other ideas to address this type-safety issue correctly? Or should we just simply ignore it? |
@lukas-reining @beeme1mr Have you had a chance to think about my comment above? It would be nice to move forward with this fix, so it's ok with me if we ignore this issue now. This is a more fundamental one, not something we should discuss here anyway. Let's open a separate issue for this, shall we? |
I think I understand the concern but it would also affect the SDK itself. I think it's best to move on with what you have and discuss possible improvements in a separate issue. |
Signed-off-by: Adam Simon <[email protected]>
I fixed the remaining failing test case as discussed above, so, as far as I'm concerned, the PR is ready for merge. |
Sorry for the delay @adams85! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the remaining failing test case as discussed above, so, as far as I'm concerned, the PR is ready for merge.
Looks good, thanks!
Done already: open-feature/js-sdk#1158 😄 |
This PR
Makes an attempt at fixing #1213 by forwarding default value to the underlying client. Also, improves type-safety and error reporting.
Related Issues
Fixes #1213