Skip to content

Fail the compliance suite on unresolved builtins - #190

Merged
sspaink merged 3 commits into
open-policy-agent:mainfrom
sspaink:test/compliance-fail-on-missing-builtins
Aug 10, 2026
Merged

Fail the compliance suite on unresolved builtins#190
sspaink merged 3 commits into
open-policy-agent:mainfrom
sspaink:test/compliance-fail-on-missing-builtins

Conversation

@sspaink

@sspaink sspaink commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

The compliance suite was passing tests it never ran. When a fixture calls a
builtin the SDK doesn't have, the evaluator throws "function not found" — and
the harness caught that error and counted the case as passed. So a missing
builtin meant all of its fixtures were green: providers.aws.sign_req had 18
passing cases before the implementation existed, and walk has 16 today.

Changes

  • A case that can't run now fails, unless its builtin is on a list of known
    gaps (known-missing-builtins.txt). Implementing a builtin means deleting its
    line — the suite fails on stale entries, so the list only shrinks.
  • Cases that assert nothing at all now fail too (no want_result, no
    want_error).
  • The job that runs the suite didn't fire for changes under opa-builtins/,
    which is where builtins are added. Now it does.

37 entries on the list are builtins that exist but are unreachable: their
META-INF/services entry is commented out, so ServiceLoader never registers
them. Un-commenting the five files surfaces 32 parity failures, so that needs
its own PR. walk's line is tied to #141.

Testing

./gradlew build green, opa test tools/policy/ 13/13. Removing
providers.aws.sign_req from the list fails all 18 of its cases as expected; as
implemented on main they run and pass. A bogus entry trips the stale check.

ComplianceTest swallowed FunctionNotFoundError, so every fixture for an
unimplemented builtin reported green. The 18 providers.aws.sign_req cases
passed for months with no implementation, and 14 walk cases still do; the
missing-builtin report was printed to stderr behind a TODO and failed
nothing.

A case whose builtin cannot be resolved now fails unless that builtin is
listed in known-missing-builtins.txt, and the list is a ratchet: the suite
also fails on entries no fixture reports as missing, so implementing a
builtin means deleting its line in the same change. Two other silent paths
are closed too — a case declaring neither want_result nor want_error, and a
want_error_code case that does not throw.

The list records 37 builtins that ship in opa-builtins sub-modules but are
unreachable because their BuiltinProvider entry is commented out, so
ServiceLoader never finds them. Registering them is left to a follow-up:
the fixtures then expose parity failures that need triage.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
test-opa-evaluator is path-filtered, so a PR touching only opa-builtins
skipped ComplianceTest entirely — exactly the change the new builtin gate
is meant to police, since the suite resolves builtins from those modules
over the BuiltinProvider SPI. A generator change (an OPA version bump)
regenerates the fixtures it reads, so that path triggers it too.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@sspaink
sspaink requested a review from a team as a code owner August 10, 2026 15:15
Close the known-missing list reader via try-with-resources; CodeQL flagged
the InputStreamReader as not always closed on method exit.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@sspaink
sspaink merged commit 58e6651 into open-policy-agent:main Aug 10, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants