rego_type_error: {built-in name}
arity mismatch
Arity is a term used to describe the number of arguments a function takes. This error happens when one of Rego's built-in functions is called with an unexpected number of arguments - the wrong arity.
This message is only shown for Rego's built-in functions, not for user-defined functions. For
errors containing has arity n, got m argument(s)
see this section.
Stage | Category | Message |
---|---|---|
compilation | rego_type_error | {built-in name} arity mismatch |
Examples
In the following example, the
split
function is called with two arguments, but it only takes one:
package policy
import future.keywords.if
import future.keywords.in
allow if "admin" in split("admin,member")
When compiled, this will result in the following error:
1 error occurred: policy.rego:6: rego_type_error: split: arity mismatch
have: (string, ???)
want: (x: string, delimiter: string)
How To Fix It
In order to find the built-in function that is causing this error, you can find the line number in the error message. E.g. in the example above, the error message says:
policy.rego:6: rego_type_error: split: arity mismatch
^ ^ ^
file line number built-in function
Here, the line number is 6
and the built-in function is split
.
Once you have found the built-in function, you can look up its expected arguments and arity in the 'Policy Reference' documentation.