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

Fixes #26075: Trying to save a group with empty criteria removes all entries #6097

Open
wants to merge 4 commits into
base: branches/rudder/8.1
Choose a base branch
from

Conversation

clarktsiory
Copy link
Contributor

@clarktsiory clarktsiory commented Dec 19, 2024

https://issues.rudder.io/issues/26075

  • LDAP : any invalid stored query in the LDAP causes errors when reading them, we should not care to validate if comparator values is not empty, validation should happen during write,read is not strict. So we need to provide a version of parser that does not apply validations to LDAP mapper
  • API : we should enforce that having value as empty string is also not valid, since this was the initial error, the parser was missing an invalid case, it should be strict against validating ""
  • UI : the save button is currently disabled only when there are form errors. But we need to disable the button also when the a criterion line has been added (or removed), this prevents from saving the query with an empty string : screenshot with the disabled button
    image

@clarktsiory clarktsiory requested a review from fanf December 19, 2024 14:36
@clarktsiory clarktsiory force-pushed the bug_26075/trying_to_save_a_group_with_empty_criteria_removes_all_entries branch from 742be8e to c90ec36 Compare December 19, 2024 14:38
@clarktsiory clarktsiory marked this pull request as draft December 19, 2024 15:05
@fanf
Copy link
Member

fanf commented Dec 19, 2024

I don't think this is the correct correction. This correction is just handling the "UX should not be annoying" part, but it doesn't correct the cause, which is: we saved something in LDAP, and we aren't able to read it back to retrieve the same state.
That invariant must be kept. I don't know where we lose it, but whatever we put in LDAP must be unserializable back.

Then, we would at least get back the same list of criteria in the group - which in the the case of AND hostname = "" will lead to an empty list of node obviously, but that's something the user can act on by themself.

And only at that point, we add the UX layer, which forces the user to see the consequences of their criteria on the node list before saving.

Copy link
Member

@fanf fanf left a comment

Choose a reason for hiding this comment

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

Please make the group unserialisable back

…es all entries

Fixes #26075: Trying to save a group with empty criteria removes all entries
@clarktsiory
Copy link
Contributor Author

PR updated with a new commit

1 similar comment
@clarktsiory
Copy link
Contributor Author

PR updated with a new commit

@clarktsiory clarktsiory marked this pull request as ready for review December 20, 2024 08:01
…a removes all entries

Fixes #26075: Trying to save a group with empty criteria removes all entries
"query": {
"select": "nodeAndPolicyServer",
"composition": "and",
"transform": "invert",
Copy link
Member

Choose a reason for hiding this comment

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

why invert ? (really to know: it's not the default queries, and not relevant to that problem, so I'm wondering)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's to have it at least covered in test somewhere, I don't think the value is tested anywhere.
I think the value for "transform" is validated before the criteria

"objectType": "node",
"attribute": "nodeId",
"comparator": "eq",
"value": ""
Copy link
Member

Choose a reason for hiding this comment

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

I'm really not sure that we want to forbid that. Things could be the empty string and being valid. And it could be different than "present/absent". Typically in overriding case, where you specifficaly want to override a description to empty string.

…criteria removes all entries

Fixes #26075: Trying to save a group with empty criteria removes all entries
@clarktsiory
Copy link
Contributor Author

PR updated with a new commit

Copy link
Member

@fanf fanf left a comment

Choose a reason for hiding this comment

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

Perhaps we will want to totally remove the raw parser in the future, the strcit seems to be a better fit for what we want. But for now, we will remain safe for the patch release.

@Normation-Quality-Assistant
Copy link
Contributor

This PR is not mergeable to upper versions.
Since it is "Ready for merge" you must merge it by yourself using the following command:
rudder-dev merge https://github.com/Normation/rudder/pull/6097
-- Your faithful QA
Kant merge: "It is beyond a doubt that all our knowledge begins with experience."
(https://ci.normation.com/jenkins/job/merge-accepted-pr/94683/console)

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