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

Config v6 #39

Merged
merged 59 commits into from
Jan 17, 2024
Merged

Config v6 #39

merged 59 commits into from
Jan 17, 2024

Conversation

novalisdenahi
Copy link
Contributor

@novalisdenahi novalisdenahi commented Oct 12, 2023

Describe the purpose of your pull request

Features/improvements:

  • Fetch new config json version (config_v6.json) and update config model
  • SDK key format validation (when client is not set up to use local-only flag overrides)
  • AND conditions
  • New condition types
    • Prerequisite flag condition
    • Segment condition
  • Changed comparison operators
    • (NOT) CONTAINS ANY OF
  • New comparison operators
    • BEFORE/AFTER
    • TEXT (NOT) EQUALS (both hashed and cleartext)
    • TEXT (NOT) STARTS/ENDS WITH ANY OF (both hashed and cleartext)
    • ARRAY CONTAINS ANY OF (both hashed and cleartext)
  • Percentage options within targeting rules
  • Percentage options based on custom attributes
  • Custom User Object attribute handling (don't force string values + autoconversions under the hood)
  • User Object attribute/comparison value trimming
  • Comparison value hashing changes (SHA256, salting)
  • Flag overrides vs. config json salt and segments
  • IEvaluationDetails.matchedTargetingRule/matchedPercentageOption properties (rename + set combinations correctly)
  • Update ConfigCatClient.getKeyAndValueFromSettingsMap

Tests:

  • Update cache key/payload tests
  • Evaluation matrix tests
    • Config v1 features (both V1 & V2)
    • Config v2 features* [x] Evaluation log tests
  • SDK key format validation
  • Custom User Object attribute handling (don't force string values + autoconversions under the hood)
  • Flag overrides vs. prerequisite flags (circular dependency, comparison value type mismatch, dependent/prereq flag overriding)
  • Flag overrides vs. config json salt and segments
  • IEvaluationDetails.matchedTargetingRule/matchedPercentageOption properties (rename + set combinations correctly)
  • Special character tests (https://trello.com/c/qh4jHrvm)
  • Trimming test (https://trello.com/c/vt8FFrSZ)

Related improvements/fixes:

Breaking changes:

  • Rework Config and related ConfigCat models to support v6.
  • Rename EvaluationDetails getMatchedEvaluationRule method to getMatchedTargetingRule and getMatchedEvaluationPercentageRule to getMatchedPercentageOption.

Requirement checklist (only if applicable)

  • I have covered the applied changes with automated tests.
  • I have executed the full automated test set against my changes.
  • I have validated my changes against all supported platform versions.
  • I have read and accepted the contribution agreement.

@novalisdenahi novalisdenahi requested a review from a team as a code owner October 12, 2023 08:32
Copy link

sonarcloud bot commented Dec 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 22 Code Smells

91.0% 91.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@adams85 adams85 left a comment

Choose a reason for hiding this comment

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

Nice job! 👍 The PR is pretty much complete, what needs to be set straight are mostly edge cases.

I found only one thing that was missed: ConfigCatClient.getKeyAndValueFromSettingsMap should also be updated to correctly traverse the new config model. See also: https://github.com/configcat/python-sdk/blob/master/configcatclient/configcatclient.py#L188

evaluateLogger.logTargetingRuleConsequence(targetingRule, error, conditionsEvaluationResult, newLine);
}
if (error != null) {
throw new RolloutEvaluatorException(error);
Copy link
Contributor

@adams85 adams85 Jan 2, 2024

Choose a reason for hiding this comment

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

low: Using exceptions to control flow is generally considered to be an anti-pattern (or at least, a code smell) as it's explained e.g. in these discussions:

So, I'd prefer an implementation that doesn't use exceptions for these expected error cases but some solution like this, which would result in a cleaner and more performant code. However, I understand that it would require a pretty extensive refactoring at this point, so I can live with the current solution if other reviewers are ok with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. That is a tricky one.
Part of me agrees with you. It is not nice when we catch the exception we just throw. I didn't want to use an extra class as a return type, and the exceptions worked fine until I added the EvaluateLogger logic. Most of the time the logger logic requires the catch and the rethrows.

At that point, I choose to go with the exceptions and do not refactor the code, but if necessary, I can do the refactor. No problem.

Let's see what the others think of it.

Copy link
Member

Choose a reason for hiding this comment

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

For now, I think we can go with the exceptions, but please create a note for later to investigate how much effort would be to do a refactor that switches to an exception-less control flow. Thanks!

src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/test/resources/evaluation/comparators/allinone.txt Outdated Show resolved Hide resolved
src/test/java/com/configcat/UserAttributeConvertTest.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/Comparator.java Outdated Show resolved Hide resolved
package com.configcat;

/**
* Describes the Rollout Evaluator User Condition Comparators.
Copy link
Contributor

Choose a reason for hiding this comment

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

low: Please consider synchronizing intellisense docs with other SDKs which has been already reviewed and approved by the UX team. For example: https://github.com/configcat/.net-sdk/tree/b6361d0c714f1198e42b914ef8633c144b4786ea/src/ConfigCatClient/Models

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@z4kn4fein z4kn4fein left a comment

Choose a reason for hiding this comment

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

Nice job!❤️ I only have some low prio requests

src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/RolloutEvaluator.java Outdated Show resolved Hide resolved
evaluateLogger.logTargetingRuleConsequence(targetingRule, error, conditionsEvaluationResult, newLine);
}
if (error != null) {
throw new RolloutEvaluatorException(error);
Copy link
Member

Choose a reason for hiding this comment

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

For now, I think we can go with the exceptions, but please create a note for later to investigate how much effort would be to do a refactor that switches to an exception-less control flow. Thanks!

Copy link
Member

@z4kn4fein z4kn4fein left a comment

Choose a reason for hiding this comment

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

Another batch for the docs 📜

src/main/java/com/configcat/ConditionAccessor.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/Config.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/Preferences.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/PercentageOption.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/PrerequisiteFlagCondition.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/SegmentCondition.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/Setting.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/SettingsValue.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/TargetingRule.java Outdated Show resolved Hide resolved
src/main/java/com/configcat/UserCondition.java Outdated Show resolved Hide resolved
Copy link
Member

@z4kn4fein z4kn4fein left a comment

Choose a reason for hiding this comment

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

🎉

Copy link

sonarcloud bot commented Jan 17, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

23 New issues
0 Security Hotspots
90.1% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@novalisdenahi novalisdenahi merged commit 2bdfa41 into master Jan 17, 2024
9 checks passed
@novalisdenahi novalisdenahi deleted the config-v6 branch January 17, 2024 14:10
@adams85 adams85 mentioned this pull request Feb 2, 2024
32 tasks
@adams85 adams85 mentioned this pull request Mar 12, 2024
33 tasks
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.

3 participants