Fix missing/incorrect @OpaBuiltin annotations for union and object.union#157
Merged
sspaink merged 1 commit intoJul 16, 2026
Conversation
sspaink
reviewed
Jul 15, 2026
sspaink
left a comment
Member
There was a problem hiding this comment.
Metadata-only PR — verified against OPA's capabilities.json / v1/ast/builtins.go and by running this repo's CapabilitiesGenerator on this branch and diffing the emitted JSON for both builtins. The collision fix is correct (object.keys keeps its own annotation on the keys method) and the getArg swap is fine. Two annotation-shape issues remain; both confirmed against the actually-generated capabilities output.
Signed-off-by: Ansh Rai <anshrai331@gmail.com>
ML-dev-crypto
force-pushed
the
fix-137-union-object-union-metadata
branch
from
July 15, 2026 18:00
d035a74 to
eacd5b8
Compare
Contributor
Author
|
Thanks for the detailed review! Good catch on both points. I've updated the object.union result annotation to use type = "object" with the appropriate dynamic key/value types, and simplified the union argument annotation to @OpaDynamic(type = "set") to match the existing convention. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both
unionandobject.unionare already fully implemented and functionallycorrect registered in their respective
builtins()maps and dispatchedproperly at runtime, so calling either from a Rego policy already works today.
The actual gap is in their
@OpaBuiltinmetadata annotations, which are usedto generate capabilities.json and docs. This PR fixes that metadata rather
than reimplementing the builtins, so the diff is smaller than the issue's
"missing builtins" framing might suggest.
Issues
#137
Changes
@OpaBuiltinannotation tounion(SetBuiltins.java).It previously had none, so it was falling back to a minimal
auto-generated capabilities entry with no description or arg types.
object.union's@OpaBuiltinannotation (ObjectBuiltins.java).It was copy-pasted from
object.keyswrong name, wrong single-argsignature, wrong description. This also meant two methods in the same
file both declared
name = "object.keys", an ambiguous collision sinceannotation-scanning order over declared methods isn't guaranteed by the
JVM. Fixing the name resolves the collision as a side effect.
(RegoSet) args[0]cast for the existinggetArghelperin
union, so a bad input type throws aTypeErrorinstead of a rawClassCastExceptionconsistent withintersection/and/orin thesame file.
Testing
./gradlew :opa-evaluator:test— full suite passes, including allcompliance cases under
TestData/v1/union/andTestData/v1/objectunion/../gradlew checkstyleMain checkstyleTest pmdMain pmdTest— clean, noviolations in either changed file.
this change (verified via
git stash): 9 inFileSystemBundleLoaderTest(Windows-specific
InvalidPathException, this repo's CI only runsubuntu-latest) and 2 inGoTimeLayoutConverterTest(unrelated tobundle/builtin code).