On OPA v1.20.2, semver.is_valid returns true for leading-zero versions (01.2.3, 1.02.3) and empty pre-release/build sections (1.2.3-, 1.2.3+), and semver.compare compares 1.02.3 and 1.2.3 as equal.
When It Runs — Run Report #RR04 · Testing what infrastructure actually does.
Provider · Component: OPA (Open Policy Agent) · SemVer built-ins —
semver.is_validandsemver.compare
Versions tested: OPA v1.20.2 (officialopa_linux_amd64_staticrelease; measured on our lab — see §2). The documentation strings and the built-in's source were checked against the live docs and the v1.20.2 source tag (2026-09-12).
Config profile: A single officialopabinary; expressions evaluated withopa eval --format pretty, in both the default (non-strict) mode and--strict-builtin-errors(see §2 and §4).
Verified on: 2026-09-22 (desk sources re-checked; v1.20.2 is still the current release) · lab measured 2026-09-12 on v1.20.2.
Affects: OPA policies that usesemver.is_validorsemver.compareas a version trust gate — for example "reject the supplied version unless it is valid SemVer," or "allow when declared ≥ minimum" (measured on v1.20.2).
TL;DR: OPA's docs describesemver.is_validas validating "that the input is a valid SemVer string", but on v1.20.2 it returnstruefor strings the SemVer spec rejects — leading-zero numbers (01.2.3,1.02.3) and empty pre-release/build sections (1.2.3-,1.2.3+) — andsemver.comparecompares1.02.3and1.2.3as equal rather than erroring the way it does for other malformed input like1.2.
Full report: https://whenitruns.substack.com/p/when-opas-semveris_valid-runs-on
Top comments (0)