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

Merged
merged 106 commits into from
Feb 2, 2024
Merged

✨ Config v6 #133

merged 106 commits into from
Feb 2, 2024

Conversation

randycoulman
Copy link
Collaborator

@randycoulman randycoulman commented Jan 9, 2024

NOTE: This PR is based on #116 and the base branch has been set accordingly. I'll rebase before merging.

Describe the purpose of your pull request

  • Feature branch for all config v6 changes

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.matched_targeting_rule/matched_percentage_option 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
  • 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.matched_targeting_rule/matched_percentage_option properties (rename + set combinations correctly)
  • Special character tests (https://trello.com/c/qh4jHrvm)

Related improvements/fixes:

Related issues (only if applicable)

https://trello.com/c/wpNt5Lqu/23-catnip

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.

@randycoulman randycoulman requested a review from a team as a code owner January 9, 2024 02:07
@randycoulman randycoulman changed the base branch from main to adopt-styler January 9, 2024 02:08
@randycoulman randycoulman marked this pull request as draft January 9, 2024 02:08
@randycoulman randycoulman marked this pull request as ready for review January 9, 2024 03:26
Base automatically changed from adopt-styler to main January 10, 2024 05:05
randycoulman and others added 23 commits January 9, 2024 21:06
* ♻️ Rename settings -> feature flags

This is a start at encapsulating the format of the Config map.

* ♻️ Introduce Config.Preferences module

Refactor existing use of preferences to use new module.

* ♻️ Encapsulate EvaluationFormula and rules

* ♻️ Move entry matching to config modules
Always return the entire config, not just the feature flags. This will allow access to preferences and segments in the v6 config where needed.
- Add setting_type field
- Rename percentage_rules -> percentage_options
- Rename rollout_rules -> targeting_rules
Update constants and test literals to new format. Extract sample config to a factory.
No need to sort maps to compare them. Also, add extra keys needed after switching to use the factory config.
Begin updating the Config sub-modules to support the new Config format.
Use v2 SDK Keys and add comments with URLs pointing to the relevant dashboard
These tests require new features that are not yet implemented, so skipping for now until the support has been added.
Rename a few of the comparators and simplify descriptions to match latest Python SDK.
@randycoulman
Copy link
Collaborator Author

@adams85 New features are implemented in 4ca885b (updated log message) and d07c796 (special characters tests).

Copy link

@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.

In the meantime we specified a few additional tests: configcat/common-js#102

Could you add these to the Elixir SDK's test suite?

Oh, and a minor observation about the sample projects: I had to apply this workaround to be able to run the samples. (I'm on Win10). Could you maybe do something about this if it can be avoided?

lib/config_cat/config/user_comparator.ex Outdated Show resolved Hide resolved
lib/config_cat/config/user_comparator.ex Outdated Show resolved Hide resolved
Brings them into line with the main app and should also fix an issue with `ssl_verify_fun` 1.1.6.
One bug fix included: Python and JS allow whitespace around numeric values whereas Elixir does not, which broke the starts_with/ends_with hashed tests while attempting to parse the length string. We add trimming to just the length string to avoid this issue and match Python/JS functionality.
Currently failing due to change in logic in JS version; will need to investigate further.
@randycoulman
Copy link
Collaborator Author

The fix for the sample projects is in 1005612. I just had to update the dependencies to match what was in the main project.

New tests are in 767ec96, 4c5acac, and 00b78c3. They are not quite passing yet, because the logging logic is different between the Python and JS versions and I ran out of time for tonight before I could resolve the remaining differences. I'll take another look at it tomorrow night.

lib/config_cat/config/user_comparator.ex Outdated Show resolved Hide resolved
Making Elixir's standard float formatting match JavaScript's was somewhat tricky.
@randycoulman
Copy link
Collaborator Author

I've addressed the two new requests, but am still working on fixing the logging tests. I'll continue tomorrow.

- Reverse names of `log_evaluating_condition_result` and `log_evaluating_condition_final_result` to better reflect their usage

- Move condition_count check to caller for `log_evaluating_condition_result`

- Move `log_evaluating_targeting_rules` to its proper alphabetical position

♻️ Refactor log_evaluating_condition_final_result

Pass a `newline?` param instead of `condition_count` to prepare for a better calculation of `newline?`.  Involved moving some increase_/decrease_indent calls around.

✨ Pass newline_before_then? flag

Based on the final evaluated condition, determine whether or not there should be a newline before the `THEN` in the logs.

This was a bit tricky to properly accumulate and pass around.
Compute and return a `newline_before_then?` flag and pass it to the
logger.
@randycoulman
Copy link
Collaborator Author

@adams85 I now have all of the tests passing. I had to add the newline_before_then logic from the JS version to get that to work, and that ended up being somewhat ugly. There's not really any way around that, though.

I believe I've now addressed all of your feedback, so I think this should be good to merge. Let me know if you find anything else.

@adams85
Copy link

adams85 commented Feb 1, 2024

Thanks for taking the trouble. 🙏 As for me, the PR is complete.

@randycoulman randycoulman merged commit b4110dd into main Feb 2, 2024
7 of 9 checks passed
@randycoulman randycoulman deleted the config-v6 branch February 2, 2024 02:11
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