» Debugging

As policies become more complex, it becomes harder to understand exactly why a policy may be behaving differently than you expect.

Prior to actively debugging, there are multiple best practices we recommend following. We recommend breaking your policy down into a set of rules. This will make it easier to understand traces and make it easier to test your policies. This should help to debug policies up to a significant complexity.

The built-in print function can be used to log data. The print output is only shown during failures or when tracing is explicitly enabled.

The print function is variadic. Each argument specifies a value to print together, concatenated with a space in between each. You can put any type as an argument and Sentinel will convert that to a human-friendly string format.


value = 42
print("the value is", value) // the value is 42

map = { "foo": false }
print(map) // { "foo": false }

The print function returns the value true so that it can also be used within rule expressions. Note that if short-circuiting is occuring within the boolean logic, the print function may never be reached. The runtime contains a special case where print will not short-circuit its own logic, so print() or expr will always evaluate expr.