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

(question) Rule query syntax validation #2201

Closed
niccolocast opened this issue Aug 8, 2024 · 3 comments
Closed

(question) Rule query syntax validation #2201

niccolocast opened this issue Aug 8, 2024 · 3 comments
Labels
question Further information is requested Stale When an issue is open for too long

Comments

@niccolocast
Copy link

Your question

Is query syntax validation without evaluation possible?
For example calling a function that returns an error if a user tries to add a malformed rule query like ((env eq "pro") and (company eq "go-feature-flag")

@niccolocast niccolocast added needs-triage A priority should be added to the issue question Further information is requested labels Aug 8, 2024
@thomaspoignant thomaspoignant removed the needs-triage A priority should be added to the issue label Aug 15, 2024
@thomaspoignant
Copy link
Owner

thomaspoignant commented Aug 15, 2024

Hi @niccolocast, I have looked at your question and checked in the nikunjy/rules what was possible to do to validate a rule.

I came to this simple solution that works partially:

func eval(rule string) error {
	ev, err := parser.NewEvaluator(rule)
	if err != nil {
		return err
	}
	_, err = ev.Process(map[string]interface{}{})
	return err
}

If the eval function error it means that the rule is invalid.
That being said it does not catch all the use-cases, your example is considered valid while it should not.

To have a bit more info, I have opened this issue nikunjy/rules#41 on the nikunjy/rules repository. If I know more about it I will let you know.

@thomaspoignant thomaspoignant removed their assignment Sep 17, 2024
Copy link
Contributor

github-actions bot commented Oct 7, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale When an issue is open for too long label Oct 7, 2024
Copy link
Contributor

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale When an issue is open for too long
Projects
None yet
Development

No branches or pull requests

2 participants