You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In rego a valid object can have any type of key. Ex:
x := {
["a", "b", "c"]: "foo"
}
Is perfectly valid.
Building objects with partial rules should therefore allow for constructing the same type of objects like:
p[["a", "b", "c"]] ="foo" { true }
Actual Behavior
You get a parse error:
> p[["a", "b", "c"]] = "foo" { true }
|
1 error occurred: 1:1: rego_parse_error: object key must be string, var, or ref, not array
p[["a", "b", "c"]] = "foo" { true }
But you can define it like...
> p[x] = "foo" {
| x := ["a", "b", "c"]
| }
|
Rule 'p' defined in package repl. Type 'show' to see rules.
Additional Info
These types of objects are somewhat dangerous since you cannot serialize them into JSON for results. However for intermediate data structures in a policy they are supported, and it seems weird that we restrict the syntax.
The text was updated successfully, but these errors were encountered:
This commit replaces the existing PEG generated parser with a parser
implemented by hand. The new parser is more efficient (avoiding old
problems with pathological input cases like {{{{{{{{{}}}}}}}} and
deeply-nested composites in general) and offers better opportunities
for improved error reporting (which has been improved already but
there is still room to grow.)
During the test process of implementing the new parser, we identified
a few issues that were present in the old parser. Those issues are
fixed by this commit.
Fixesopen-policy-agent#1251Fixesopen-policy-agent#501Fixesopen-policy-agent#2198Fixesopen-policy-agent#2199Fixesopen-policy-agent#2200Fixesopen-policy-agent#2201Fixesopen-policy-agent#2202Fixesopen-policy-agent#2203
Co-authored-by: Torin Sandall <torinsandall@gmail.com>
Co-authored-by: Patrick East <east.patrick@gmail.com>
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Signed-off-by: Patrick East <east.patrick@gmail.com>
This commit replaces the existing PEG generated parser with a parser
implemented by hand. The new parser is more efficient (avoiding old
problems with pathological input cases like {{{{{{{{{}}}}}}}} and
deeply-nested composites in general) and offers better opportunities
for improved error reporting (which has been improved already but
there is still room to grow.)
During the test process of implementing the new parser, we identified
a few issues that were present in the old parser. Those issues are
fixed by this commit.
Fixes#1251Fixes#501Fixes#2198Fixes#2199Fixes#2200Fixes#2201Fixes#2202Fixes#2203
Co-authored-by: Torin Sandall <torinsandall@gmail.com>
Co-authored-by: Patrick East <east.patrick@gmail.com>
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Signed-off-by: Patrick East <east.patrick@gmail.com>
Expected Behavior
In rego a valid object can have any type of key. Ex:
Is perfectly valid.
Building objects with partial rules should therefore allow for constructing the same type of objects like:
Actual Behavior
You get a parse error:
But you can define it like...
Additional Info
These types of objects are somewhat dangerous since you cannot serialize them into JSON for results. However for intermediate data structures in a policy they are supported, and it seems weird that we restrict the syntax.
The text was updated successfully, but these errors were encountered: