This release contains a mix of new features, performance improvements and bug fixes. Notably:
- Enforcement of bundle structure: now rooted at their
.manifestfile - Lucene (Solr) target for the Compile API
- Hardening of the MySQL Compile API target: use of
startswith,endswithandcontainsbuilt-in functions is rejected - Improvements to the rule indexer
- A new
json.pointer_escapebuilt-in function
Note
Help us improve OPA, and fill out the 2026 OPA Community Survey!
Bundles are rooted at their .manifest file (#9459)
Breaking change: OPA now treats the directory containing a bundle's .manifest file as the bundle root, as the
bundle documentation describes.
Previously, the root depended on the path a bundle was loaded from, which made bundle contents, data placement,
and signatures depend on how a path was typed.
- Bundle directories (
opa build -b,opa run -b,opa eval -b,opa sign --bundle, ...) are rooted at
the directory containing.manifest, even when it is nested below the provided path. Files above it are not
part of the bundle.opa buildandopa signwarn about policy and data files they leave out, but other
commands do not, so keep other.manifestfiles (e.g., test fixtures) out of directories loaded as bundles. - Bundle tarballs loaded from disk must have
.manifestat the root of the archive.opa buildalways writes
it there. - Signatures: file names in
.signatures.jsonare relative to the bundle root, with/separators on every
platform. Bundles signed byopa sign <dir>oropa build -b <dir>with older OPA versions must be re-signed,
and--exclude-files-verifypatterns may need updating. opa buildwith multiple bundles places each bundle's files under the path it was given with-b, with a
new.manifestat the root. Leading..segments are replaced with the name of the directory they refer to.
Merging fails when two bundles would be placed under the same path.opa signwith multiple bundle paths
names files under each bundle's path, likeopa builddoes when merging. A mergedopa buildoutput has its
own new.manifest, so signatures from multiple separate source bundles cannot be used to verify a merged build.opa build -t planand-t wasmreplace any plan, or wasm resolvers that were carried in from the input bundles..manifest,.signatures.json, andpatch.jsonmust be at the bundle root, and only files named exactly
.manifestare treated as manifests.
For example, consider this tarball, built without opa build:
$ tar tzf bundle.tar.gz
bundle/.manifest
bundle/data.json
bundle/authz.rego
Previously, opa run -b bundle.tar.gz loaded it with bundle/data.json placed under data.bundle. It is now
rejected because .manifest is not at the root of the archive. Running opa build -b bundle/ on the extracted
directory produces a bundle rooted at bundle/, with data.json placed at the root of data.
To avoid breaking existing deployments, bundles that the bundle plugin downloads over HTTP or from an OCI registry
(and their persisted copies) are still loaded as before, and OPA logs a warning each time a bundle with a misplaced .manifest, .signatures.json,
or patch.json is loaded. These bundles will fail to load in a future OPA release. Rebuild them with
opa build to place the manifest at the root.
Go API: the bundle.Reader expects bundle-relative descriptor paths, so directory loaders configured with the
SlashRooted or Passthrough path formats now have their manifests rejected. When Reader.WithBaseDir is used,
module paths include the manifest's directory, which directory loaders report through a RootOffset() string
method. Custom loaders that wrap a directory loader should forward RootOffset.
Authored by @philipaconrad
Lucene (Solr) target for the Compile API (#9376)
The Compile API can now translate a policy into a Lucene query for Solr's fq or q, with
Accept: application/vnd.opa.lucene.solr+json. The one unknown is the document searched:
# METADATA
# scope: package
# compile:
# unknowns: [input.doc]
package filters
include if {
input.doc.owner == input.user
input.doc.level >= 3
not input.doc.status == "draft"
}
For the user alice, this compiles to (owner:"alice" AND level:[3 TO *] AND NOT status:"draft").
Multi-valued fields are compared by their elements, as in "a" in input.doc.tags; schemas
annotations declare which fields are, and
solr_schema.rego generates them from
Solr's Schema API. The target can't be combined with others in a multitarget request.
See Lucene filters.
Authored by @srenatus
Compile API: no startswith, endswith or contains for MySQL (#9624)
Breaking change: the MySQL target rejects startswith, endswith and contains, as the SQLite target
already did. They were translated to LIKE, which is case- and accent-insensitive in MySQL's default
collations, so startswith(input.fruits.name, "APP") also matched apple. Policies using them now fail
to compile for application/vnd.opa.sql.mysql+json, and for multitarget requests that include mysql.
Reported by @kianwang0610, authored by @srenatus
Generated bundles
A bundle whose policies are generated, for example from a policy database, can say so in its manifest:
{
"revision": "...",
"roots": ["authz"],
"generated": true
}
OPA then parses its policies without source locations. In a benchmark of 20000 generated rules, that cut
the memory the compiled policies hold by 40%. Annotations are kept. See the
manifest documentation.
Authored by @srenatus
Rule indexing covers more ways of saying "any of these"
The rule index now narrows down rules written with:
- a local iterating a literal set, array or object, in any indexable statement:
some g in {"devs", "ops"}; data.groups[g].members[input.subject]; - collection lookups in the operands of
andandor:
{data.groups.devs.members[input.subject]} or {data.groups.ops.members[input.subject]}; - a collection lookup keyed by any element of a collection:
data.groups.devs.members[input.subjects[_]].
Looking up a key in a collection in base data also no longer converts the store's data on every query:
in benchmarks of 500 rules gated by group membership, that takes 40-55% off evaluation and partial
evaluation where every candidate is evaluated.
- ast: Index a collection lookup keyed by an element of a collection (#9461) authored by @srenatus
- ast: Index collection lookups in
and/oroperands (#9461) authored by @srenatus - ast: Index expressions over a local iterating a literal (#9461) authored by @srenatus
- ast: Keep a rule indexed as "anything" for
inwith a var member (#9506) authored by @srenatus, reported by @kholia - rego: Compare indexed and unindexed evaluation for every index condition (#9525) authored by @srenatus
- topdown: Ask the index candidates whether a rule depends on unknowns (#9570) authored by @srenatus
- topdown: Report key conflicts in indexed object comprehensions (#9613) authored by @srenatus
New json.pointer_escape built-in function (#9591)
Escapes a string so it can be used as one reference token of a JSON Pointer, as defined in RFC 6901.
The characters ~ and / are replaced with ~0 and ~1.
For example: json.pointer_escape(\"a/b~c\") results in \"a~1b~0c\".
Authored by @charlieegan3
Runtime, SDK, Tooling
- cmd(fmt): Honor
--drop-v0-importswhen formatting stdin (#9619) authored by @FayezBast - cmd/inspect: Show labels metadata with -a (#9504) authored by @srenatus, reported by @humbertoc-silva
- cmd: Add --v2-compatible flag (#9251) authored by @sspaink, reported by @johanfylling
- cmd: Replace --v2-compatible with --compatible= (#9496) authored by @sspaink
- compile: Compile without indices where nothing evaluates (#9605) authored by @srenatus
- compile: Release the checking compiler after a rego build (#9604) authored by @srenatus
- format: Preserve nested comparison grouping (#9407) authored by @rudraa2005, reported by @alecthomas
- plugins/bundle: Activate generated bundles incrementally (#9359) authored by @srenatus
- plugins/logs: Copy JSON-shaped values natively for console logs (#9576) authored by @sspaink
- plugins/logs: Split oversized chunks without decoding them (#9577) authored by @sspaink
- plugins: Close the Wasm resolvers a bundle update replaces (#9513) authored by @jbpros
- rego: Close the Wasm engine after Rego.Eval (#9513) authored by @jbpros
- rego: Close the Wasm resolvers a prepared query loaded (#9513) authored by @jbpros
- rego: Drop the test that Close does nothing on the default target (#9513) authored by @jbpros
- rego: Exclude wasm compile time from context timeout test (#9455) authored by @sspaink
- rego: Test a Wasm resolver result not named "result" (#9541) authored by @jbpros
- repl: Allow implicit function bodies (#9539) authored by @devjoshi2005, reported by @anderseknert
- server: Fix oversized request body status in v2-compatible mode (#9497) authored by @darshpatel1052
- storage/inmem: Speed up NonEmpty conflict checks (#9545) reported and authored by @believetech-orw
- tester: Add --strict-builtin-errors to opa test (#6816) authored by @oleksii-udovychenko, reported by @selaux
- tester: Close the Wasm engine after each test (#9513) authored by @jbpros
- tester: Close the Wasm engine of a benchmark (#9513) authored by @jbpros
- tester: Do not wait forever to evaluate a closed engine (#9513) authored by @jbpros
- wasm: Return an error when the result has no "result" key (#9541) authored by @jbpros
- wasm: Replace non-object values when upserting for with (#6304) authored by @sspaink, reported by @srenatus
Compiler, Topdown and Rego
- ast: Allocate each parser term cache entry once (#9585) authored by @charlieegan3
- ast: Allocate type tree children lazily (#9572) authored by @charlieegan3
- ast: Allow iterating empty collections in the type checker (#9517) authored by @sspaink, reported by @kholia
- ast: Allow keys of empty collections in rules replaced by
with(#9529) authored by @sspaink - ast: Allow mixed rule kinds on disjoint ref heads (#7182) authored by @oleksii-udovychenko, reported by @anderseknert
- ast: Compare numbers beyond float64 precision exactly (#9508) authored by @srenatus
- ast: Compiler tweaks to improve perf (-12% allocs) (#9567) authored by @anderseknert
- ast: Correct default rule location text (#9516) authored by @charlieegan3
- ast: Decode
everyexpressions from JSON (#9544) authored by @srenatus - ast: Decode
somedeclarations from JSON (#9544) authored by @srenatus - ast: Fix negative number location text (for issue #9531) (#9531) authored by @devjoshi2005, reported by @anderseknert
- ast: Give a function without a body the location of its whole statement (#9579) authored by @srenatus
- ast: In lazyObj, check cache before digging up path (#9460) authored by @srenatus
- ast: Parse modules without locations (#9485) authored by @srenatus
- ast: Parse not {..}[..] as a ref on a set literal under v2 (#9540) authored by @sspaink, reported by @anderseknert
- ast: Probe base data collections without converting them (#9447) authored by @srenatus
- ast: Reduce size of
Headstruct from 128 to 96 bytes (#9607) authored by @anderseknert - ast: Report template string errors once (#8243) authored by @sspaink, reported by @anderseknert
- ast: Reuse compiled rules across compiles (#9359) authored by @srenatus
- ast: Say when an array index is out of bounds (#9505) authored by @THEpranavsomalraju, reported by @anderseknert
- ast: Set scan opts when needed to reduce allocs (#9583) authored by @charlieegan3
- ast: Skip per-rule recursion check when graph sorts (#9582) authored by @charlieegan3
- ast: Skip repeated rule names when resolving refs (#9602) authored by @charlieegan3
- ast: Value only built-in type env (#9586) authored by @charlieegan3
- ast: ast, bundle, plugins/bundle: remove rule reuse (#9560) authored by @srenatus
- ast: don't copy expressions before rewriting (#9580) authored by @anderseknert
- bundle: Let the reader leave out rules the compiler can reuse (#9359) authored by @srenatus
- bundle: Parse at most GOMAXPROCS modules at once (#9484) authored by @srenatus
- bundle: Read generated bundles without locations (#9359) authored by @srenatus
- eval: A few more fixes reducing allocations (#9514) authored by @anderseknert
- eval: Store and retrieve call operands from pool (#9501) authored by @anderseknert
- perf: Add sync pool for evalTermNext, improve hasCollisions (#9550) authored by @anderseknert
- perf: Allow iterate objects without allocations (#9481) authored by @anderseknert
- perf: Make sink writer perform on par with bytes.Buffer (#9537) authored by @anderseknert
- perf: Non-allocating out-of-bounds array.slice (#9549) authored by @anderseknert
- topdown/walk: Alloc less when building walk paths (#9554) authored by @charlieegan3
- topdown: Add compliance cases for empty and undefined inputs (#9499) authored by @srenatus
- topdown: Allocate less in replace and replace_n (#9590) authored by @charlieegan3
- topdown: Avoid compiling unused regexes in regex.template_match (#9569) authored by @SayokoAkiike
- topdown: Bound magnitude of units.parse/parse_bytes results (#9404) reported and authored by @leandrocosta-git
- topdown: Corpus cases (#9564) authored by @kroekle
- topdown: Cover the ordering of values of different types (#9509) authored by @srenatus
- topdown: Cover time.date, clock, weekday and diff with small timestamps (#9498) authored by @srenatus
- topdown: Fix ceil and floor of negative fractions above -1 (#9562) reported by @kroekle
- topdown: Fix net.cidr_merge panic on IPv4-mapped IPv6 CIDRs (#9528) reported and authored by @nikpivkin
- topdown: Lazily allocate comp. cache children (#9573) authored by @charlieegan3
- topdown: Make the partial object collision check linear (#9612) authored by @srenatus
- topdown: Remove stale comment re sync.Pool (#9571) authored by @charlieegan3
- topdown: Reuse pooled step continuation for bare terms (#9614) authored by @charlieegan3
- topdown: Use YAML cases for replace tests (#9597) authored by @charlieegan3
Docs, Website, Ecosystem
- docs: Add blog post on opa-java-wasm moving to the OPA org (#9515) authored by @andreaTP
- docs: Amend security reporting docs to cover scanners (#9551) authored by @anderseknert
- docs: Document number representation differences in Wasm (#3298) authored by @ajaykr0905, reported by @srenatus
- docs: Explain http_request_duration_seconds buckets (#5195) authored by @sspaink, reported by @tsandall
- docs: Fix broken links from link checker report (#9463) authored by @sspaink, reported by @github-actions
- docs: Fix the examples of the data filtering fragment (#9630) authored by @srenatus
- docs: Fix typos (#9594) authored by @Adham-Kiwan
- docs: Make a few index examples more clear (#9482) authored by @charlieegan3
- docs: ocp: document git source depth (#9503) authored by @srenatus
- ecosystem: Add formal.ai (#9511) authored by @charlieegan3
- website: Update security docs (#9476) authored by @charlieegan3
- website: Add redirect for wrong security.txt path (#9477) authored by @charlieegan3
- website: Show live code query, highlight output some more (#9533) authored by @srenatus
Miscellaneous
- types: Decode set types without an element type (#9544) authored by @srenatus
- types: Decode type JSON in linear time (#9473) authored by @srenatus
- util/test: don't panic in MakeTempFS when creating files fails (#9578) authored by @sspaink
- Dependency updates; notably:
- build(go): Bump to 1.27.4 (#9543) authored by @srenatus
- build(deps): Bump github.com/agnivade/levenshtein from 1.2.1 to 1.2.2
- build(deps): Bump github.com/foxcpp/go-mockdns from 1.2.0 to 1.3.0
- build(deps): Bump github.com/gobwas/glob from 1.0.0 to 1.1.0
- build(deps): Bump github.com/huandu/go-sqlbuilder from 1.43.0 to 1.44.1
- build(deps): Bump github.com/klauspost/compress from 1.20.0 to 1.20.4
- build(deps): Bump github.com/lestrrat-go/jwx/v3 from 3.3.0 to 3.4.0
- build(deps): Bump github.com/prometheus/client_golang from 1.24.1 to 1.25.0
- build(deps): Bump github.com/sergi/go-diff from 1.4.0 to 1.4.5
- build(deps): Bump github.com/spf13/pflag from 1.0.10 to 1.1.0
- build(deps): Bump github.com/vektah/gqlparser/v2 from 2.5.58 to 2.5.64
- build(deps): bump go.opentelemetry.io deps from 1.46.0/0.71.0 to 1.47.0/0.72.0
- build(deps): Bump go.opentelemetry.io/proto/otlp from 1.11.0 to 1.11.1
- build(deps): Bump go.yaml.in/yaml/v3 from 3.0.5 to 3.0.6
- build(deps): Bump golang.org/x/sync from 0.23.0 to 0.25.0
- build(deps): Bump golang.org/x/term from 0.46.0 to 0.48.0
- build(deps): Bump golang.org/x/text from 0.42.0 to 0.44.0
- build(deps): Bump golang.org/x/net from v0.60.0 to v0.62.0 (#9555) authored by @anderseknert
- build(deps): Bump google.golang.org/grpc from 1.84.0 to 1.85.0
- build(deps): Bump gopkg.in/ini.v1 from 1.67.3 to 1.68.0
- build(deps): Bump oras.land/oras-go/v2 from 2.6.2 to 2.7.0