Skip to content
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: TypeMismatch error is handled #170

Merged
merged 2 commits into from
Nov 6, 2024
Merged

Conversation

fabriziodemaria
Copy link
Member

@fabriziodemaria fabriziodemaria commented Nov 5, 2024

This is an important fix to signal users that the returned value is the default value due to a type mismatch, rather than looking like the variant's value returned by the backend.

This happens when the user tries to get a value with a type that is not the the same type defined in the backend schema for that value.

@@ -30,7 +30,7 @@ class ConfidenceIntegrationTests: XCTestCase {
.withContext(initialContext: ctx)
.build()
try await confidence.fetchAndActivate()
let intResult = confidence.getEvaluation(key: "\(resolveFlag).my-integer", defaultValue: "1")
Copy link
Member Author

Choose a reason for hiding this comment

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

This started failing after our fix, good outcome 👍

Comment on lines +88 to +95
if parsedValue == .init(null: ()) {
return Evaluation(
value: defaultValue,
variant: resolvedFlag.variant,
reason: resolveReason,
errorCode: nil,
errorMessage: nil
)
Copy link
Member Author

Choose a reason for hiding this comment

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

The expected behaviour when getting null from backend is to use the client-side default value

@fabriziodemaria fabriziodemaria merged commit 6a04cda into main Nov 6, 2024
8 checks passed
@fabriziodemaria fabriziodemaria deleted the fix-typemismatch branch November 6, 2024 08:32
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.

2 participants