OPA v0.34.0 Release #44
peteroneilljr
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This release includes a number of enhancements and fixes. In particular, this
release adds a new keyword for membership and iteration (
in
) and a specializedbuilt-in function (
print
) for debugging.The
in
operatorThis release adds a new
in
operator that provides syntactic sugar forreferences that perform membership tests or iteration on collections (i.e.,
arrays, sets, and objects.) The following table shows common patterns for arrays
with the old and new syntax:
7 == arr[_]
7 in arr
not 7 in arr
x := arr[_]
some x in arr
For more information on the
in
operator see Membership and iteration:in
in the docs.
The
print
functionThis release adds a new
print
function for debugging purposes. Theprint
function can be used to output any value inside of the policy. The
print
function has special handling for undefined values so that execution does not
stop if any of the operands are undefined. Instead, a special marker is emitted
in the output. For example:
Given the policy above, we can see the output of the
print
function via STDERR when usingopa eval
:Output:
If the username, subject, or entire input document was undefined, the
print
function will still execute:Output:
The
print
function is integrated into theopa
subcommands, REPL, server, VSCode extension, and the playground. Library users must opt-in to
print
statements. For more information see the Debugging section in the docs.
Enhancements
opa test
: Change exit status when tests are skipped (#3773) authored by @kirk-pattonopa fmt
: Keep new lines in between function arguments (#3836) reported by @anbrsapopa inspect
: Add experimental subcommand for bundle inspection (#3754)Fixes
Bundles/API: When deleting a policy, the check determining if it's bundle-owned was using the path prefix, which would yield false positives under certain circumstances.
It now checks the path properly, piece-by-piece. (#3863 authored by @edpaget
CLI: Using
--set
with null value again translates to empty object (#3846)Rego: Forbid dynamic recursion with hidden (
system.*
) document (#3876Rego: Raise conflict errors in functions when output not captured (#3912)
This change has the potential to break policies that previously evaluated successfully!
See Backwards Compatibility notes below for details.
Experimental disk storage: React to "txn too big" errors (#3879), reported and authored by @floriangasc
Documentation
http.send
and extension docs about side-effects in other systems (#3922) (#3893)Miscellaneous
input
references (#3891)Backwards Compatibility
Function return values need to be well-defined: for a single input
x
, the function'soutput
f(x)
can only be one value. When evaluating policies, this condition had notbeen ensured for function calls that don't make use of their values, like
Before,
data.p.r
evaluated totrue
. Now, it will (correctly) return an error:In more realistic settings, this can be encountered when true/false return values
are captured and returned where they don't need to be:
In this example, any function input containing
"any"
would make the function yieldtwo different results:
true
, matching the"any"
argument.glob.match
call --false
.The fix here would be to not capture the return value in the function bodies:
The
github.com/open-policy-agent/opa/runtime#NewLoggingHandler
function nowrequires a logger instance. Requiring the logger avoids the need for the
logging handler to depend on the global logrus logger (which is useful for
test purposes.) This change is unlikely to affect users.
Beta Was this translation helpful? Give feedback.
All reactions