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

Forbid underscore as rule name #7272

Open
anderseknert opened this issue Jan 15, 2025 · 1 comment
Open

Forbid underscore as rule name #7272

anderseknert opened this issue Jan 15, 2025 · 1 comment

Comments

@anderseknert
Copy link
Member

Harmless, but still, a wildcard rule name doesn't make sense 😄

package p

_ if true
opa eval -f pretty -d p.rego data.p
{
  "$0": true
}
@anderseknert
Copy link
Member Author

Had a look at this, and have some code I can push to resole the issue. Had a test failure here though, and that test clearly suggests intention to allow _ as a rule name. I'm not sure why this would be though 🤔

opa/v1/ast/parser_test.go

Lines 2267 to 2274 in 2136920

assertParseRule(t, "wildcard name", `_ { x == 1 }`, &Rule{
Head: &Head{
Name: "$0",
Reference: Ref{VarTerm("$0")},
Value: BooleanTerm(true),
},
Body: MustParseBody(`x == 1`),
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

1 participant