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 #23

Merged
merged 55 commits into from
Apr 4, 2024
Merged

Config v6 #23

merged 55 commits into from
Apr 4, 2024

Conversation

adams85
Copy link
Contributor

@adams85 adams85 commented Feb 26, 2024

Implements config v6 support.

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
  • EvaluationDetails.matchedTargetingRule/matchedPercentageOption properties (rename + set combinations correctly)
  • Update ConfigCatClient.getKeyAndValue

Tests:

  • Update cache key/payload tests
  • Evaluation matrix tests
    • Config v1 features (both V1 & V2)
    • Config v2 features
  • 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
  • EvaluationDetails.matchedTargetingRule/matchedPercentageOption properties (rename + set combinations correctly)
  • Special character tests (https://trello.com/c/qh4jHrvm)
  • Comparison attribute and comparison value trimming tests (https://trello.com/c/vt8FFrSZ)
  • Comparison attribute conversion to canonical string representation tests (https://trello.com/c/CZgGrrcb)

Related improvements/fixes:

Additional improvements:

  • Improve getValueDetails API (see breaking changes). Also, add the getValueDetails counterpart of the getValue overload that doesn't require a default value.
  • Handle unexpected errors in the forceRefresh and the evaluation methods (getValue, etc.) to stop potential unhandled exceptions thrown by the evaluation logic from bringing down the consumer's application.
  • Return information about the success of the operation (RefreshResult) from the forceRefresh method.
  • Add exception message to the log format of the default logger.
  • When evaluation fails and there is a related exception, also expose it in EvaluationDetails via the new errorException field. Also, expose the exception to the onError hook callbacks.
  • When forceRefresh fails and there is a related exception, also expose it in RefreshResult via the new errorException field.

Additional bugfixes:

  • Correct the config service logic to return the error message in case config fetching fails.

Breaking changes:

  • Change the return type of ConfigCatClient::get from C pointer to shared_ptr to prevent use after free issues.
  • Change the type of the user parameter of evaluation methods (getValue & co.) from C pointer to shared_ptr. Also, change the type of the EvaluationDetails.user field to shared_ptr to prevent use after free issues.
  • Change the type of the ConfigCatUser.user field from std::unordered_map<std::string, std::string> to std::unordered_map<std::string, ConfigCatUser::AttributeValue> to allow other values than std::string.
  • Make EvaluationDetails generic and change the return type of getValueDetails overloads to return specialized EvaluationDetails objects that contain a value of the same type as the default value.
  • Change the return type of getValue(const std::string&, const ConfigCatUser*) and getKeyAndValue from std::shared_ptr to std::optional (for consistency and to remove unnecessary heap allocation).
  • Add an extra parameter of type std::exception_ptr to the onError hook callback.
  • Make Settings const in the parameter of the onConfigChanged hook callback as it is not supposed to be modified by consumers.
  • Rename the error field to errorMessage in EvaluationDetails (and also make it optional).
  • Rename the matchedEvaluationRule field to matchedTargetingRule and the matchedEvaluationPercentageRule field to matchedPercentageOption in EvaluationDetails.
  • Make the EvaluationDetails.variationId field optional.
  • Rework config model (Config and related structs/enums).
  • Pass the potential exception as an optional parameter to the ILogger.log method.
  • Remove the ConfigCatLogger, ConfigEntry and SettingResult types from the public API.
  • Add an abstract getBehavior method to the OverrideDataSource class.
  • Use int32_t instead of int for integer setting values for better portability (on most platforms int32_t is just an alias of int).

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.

@adams85 adams85 requested a review from a team as a code owner February 26, 2024 16:17
@adams85 adams85 force-pushed the config-v6 branch 2 times, most recently from 663ffdc to b581b1e Compare February 26, 2024 16:41
@adams85 adams85 marked this pull request as draft February 26, 2024 17:21
…c + add missing getValueDetails overload w/o defaultValue + eliminate getValue code redundancy
…SDK bringing down the consumer's app) + add the captured exception to EvaluationDetails + add the exception message to the log + change the return type of getKeyAndValue to std::optional for consistency
@adams85 adams85 force-pushed the config-v6 branch 19 times, most recently from f239575 to 571ee1c Compare March 2, 2024 09:36
@kp-cat kp-cat force-pushed the config-v6 branch 3 times, most recently from 44b58e2 to 803acd5 Compare April 2, 2024 21:50
z4kn4fein
z4kn4fein previously approved these changes Apr 3, 2024
@kp-cat kp-cat merged commit ac7f452 into main Apr 4, 2024
4 checks passed
@kp-cat kp-cat deleted the config-v6 branch April 4, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants