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

#340 fix match["query_key"] malformation #346

Merged
merged 4 commits into from
Jul 25, 2021

Conversation

AntoineBlaud
Copy link
Contributor

No description provided.

@jertel
Copy link
Owner

jertel commented Jul 17, 2021

Thanks for the PR. Some unit tests to cover that new logic would be helpful, to ensure no one accidentally breaks your logic on future commits.

@mrfroggg
Copy link
Contributor

We have many field names with . in them in our Elasticsearch and I use many of them in our query_key.
I have not tested this PR, but seeing _expand_string_into_dict and expand_string_into_dict, I have a doubt that this could break my setup.
What do you think?

@JeffAshton
Copy link
Contributor

We have many field names with . in them in our Elasticsearch and I use many of them in our query_key.
I have not tested this PR, but seeing _expand_string_into_dict and expand_string_into_dict, I have a doubt that this could break my setup.
What do you think?

I agree with @jertel here. Yelp didn't do a great job of ensuring quality tests, and the rest of us need to pay down that debt. This should be an easy deterministic thing to test.

@AntoineBlaud
Copy link
Contributor Author

AntoineBlaud commented Jul 19, 2021

@mrfroggg it can break your setup only if you use enhancement by doing some works with the query key.
@jertel how can I create a match from specific documents inside a test method ? Do you have a example ? Thank you.

@jertel
Copy link
Owner

jertel commented Jul 20, 2021

@AntoineBlaud The two new functions you added won't need mocked documents, those unit tests should be relatively simple since you're dealing with simplistic inputs, such as generic dicts, strings, etc. As far as unit testing the check_matches function, look at tests/rules_test.py to see what's already being unit tested.

@mrfroggg I agree, if you look at #340 I raised this concern as well. If it's not possible to have a "foo" key and a "foo.bar" key in the same elastic data structure then another option would be to add a configurable toggle to enable or disable the string-to-dict conversion. Then we'd have to decide which would be the default toggle: If we default it to enabled, it could break existing users, but then the fix is a simple toggle back to false, assuming they read the release notes. Doing this would allow us to deprecate the old method of "foo.bar" keys and eventually remove it after some time. If instead we default it to disabled then people like @AntoineBlaud will have to enable it manually to accomplish their desired behavior. Yet long term is seems that converting these to dicts for consistency with the other rule types is the better way forward. Thoughts?

AntoineBlaud and others added 2 commits July 23, 2021 11:19
[+] add test for expend_string_into_dict
[+] add check in test_metric_match and test_percentage_match
jertel
jertel previously approved these changes Jul 25, 2021
Copy link
Owner

@jertel jertel left a comment

Choose a reason for hiding this comment

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

This PR has been out here for 9 days, giving everyone sufficient time to comment or request changes. As there are no further comments I am merging this today. However, if there ends up being a unexpected difficulties by the community from this we can react quickly and release a new version with a configuration toggle.

@jertel jertel merged commit c19ae9a into jertel:master Jul 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants