-
Notifications
You must be signed in to change notification settings - Fork 30
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
Better display for errors::Logic
#191
Conversation
divarvel
commented
Oct 26, 2023
•
edited
Loading
edited
@@ -168,9 +171,9 @@ pub enum Signature { | |||
#[derive(Error, Clone, Debug, PartialEq, Eq)] | |||
#[cfg_attr(feature = "serde-error", derive(serde::Serialize, serde::Deserialize))] | |||
pub enum Logic { | |||
#[error("a rule provided by a block is generating facts with the authority or ambient tag, or has head variables not used in its body")] | |||
#[error("a rule provided by a block is producing a fact with unbound variables")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wanted to completely remove it, but it's still used. the strange thing is that it explicitly mentions block rules. Where is the error for authorizer rules with unbound variables in facts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after a bit of digging:
- unbound variables are checked by the parser when constructing rules, so all rules constructed by the parser will be checked, regardless of their origin, and the error will be a parser error, not a
Logic
error - this error can indeed only happen when a block is added to the authorizer, so adding a broken rule to the authorizer will not be caught here (rules constructed by the parser will be ok, it can only happen for manually constructed rules)
- rules with unbound variables in head will not generate any fact (but not crash)
I think the ergonomics of this could be improved:
- by being clearer on invariants that
Rule
and friends should guarantee, no matter how they were constructed (this would be a bit of work because i think that we should do it in other places as well) - for now, by calling
validate_variables
when adding rules to the authorizer, not only rules blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, we should avoid those kinds of footguns
errors::Logic
04675aa
to
61e5f86
Compare
CodSpeed Performance ReportMerging #191 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v5 #191 +/- ##
==========================================
+ Coverage 65.57% 65.61% +0.03%
==========================================
Files 27 27
Lines 6987 6994 +7
==========================================
+ Hits 4582 4589 +7
Misses 2405 2405 ☔ View full report in Codecov by Sentry. |
b28199c
to
c1eef6d
Compare
c1eef6d
to
eb2a7c4
Compare