diff --git a/runtime/src/main/java/dev/cel/runtime/planner/ProgramPlanner.java b/runtime/src/main/java/dev/cel/runtime/planner/ProgramPlanner.java index d48726cf2..3782d1860 100644 --- a/runtime/src/main/java/dev/cel/runtime/planner/ProgramPlanner.java +++ b/runtime/src/main/java/dev/cel/runtime/planner/ProgramPlanner.java @@ -81,11 +81,8 @@ public final class ProgramPlanner { private static final String JSON_NAME_EXTENSION = "json_name"; private static final String SELECT_OPTIMIZATION_EXTENSION = "select_optimization"; - private static final ImmutableMap SUPPORTED_RUNTIME_EXTENSIONS = - ImmutableMap.of( - CEL_BLOCK_EXTENSION, Version.of(1, 1), - JSON_NAME_EXTENSION, Version.of(1, 1), - SELECT_OPTIMIZATION_EXTENSION, Version.of(1, 0)); + private static final ImmutableSet SUPPORTED_RUNTIME_EXTENSIONS = + ImmutableSet.of(CEL_BLOCK_EXTENSION, JSON_NAME_EXTENSION, SELECT_OPTIMIZATION_EXTENSION); private final CelTypeProvider typeProvider; private final CelValueProvider valueProvider; @@ -865,11 +862,8 @@ private static PlannerContext create(CelAbstractSyntaxTree ast, CelOptions optio continue; } Version version = extension.version(); - Version supportedVersion = SUPPORTED_RUNTIME_EXTENSIONS.get(extension.id()); checkArgument( - supportedVersion != null - && version.major() == supportedVersion.major() - && version.minor() <= supportedVersion.minor(), + SUPPORTED_RUNTIME_EXTENSIONS.contains(extension.id()) && version.major() == 1, "unsupported CEL extension: %s@%s.%s", extension.id(), version.major(), diff --git a/runtime/src/test/java/dev/cel/runtime/planner/ProgramPlannerTest.java b/runtime/src/test/java/dev/cel/runtime/planner/ProgramPlannerTest.java index 7921d80b6..4e006cdd4 100644 --- a/runtime/src/test/java/dev/cel/runtime/planner/ProgramPlannerTest.java +++ b/runtime/src/test/java/dev/cel/runtime/planner/ProgramPlannerTest.java @@ -355,10 +355,8 @@ public void plan_notSet_throws() { @Test @TestParameters("{id: 'unknown', major: 1, minor: 0}") @TestParameters("{id: 'select_optimization', major: 2, minor: 0}") - @TestParameters("{id: 'select_optimization', major: 1, minor: 1}") @TestParameters("{id: 'cel_block', major: 0, minor: 0}") - @TestParameters("{id: 'cel_block', major: 1, minor: 2}") - @TestParameters("{id: 'json_name', major: 1, minor: 2}") + @TestParameters("{id: 'json_name', major: 2, minor: 0}") public void plan_unsupportedRuntimeExtension_throws(String id, int major, int minor) { CelAbstractSyntaxTree ast = newAstWithExtensions( @@ -377,9 +375,9 @@ public void plan_supportedOrNonRuntimeExtensions_succeeds() throws Exception { CelAbstractSyntaxTree ast = newAstWithExtensions( Extension.create("cel_block", Version.of(1, 0), Component.COMPONENT_RUNTIME), - Extension.create("cel_block", Version.of(1, 1), Component.COMPONENT_RUNTIME), - Extension.create("json_name", Version.of(1, 1), Component.COMPONENT_RUNTIME), - Extension.create("select_optimization", Version.of(1, 0), Component.COMPONENT_RUNTIME), + Extension.create("cel_block", Version.of(1, 2), Component.COMPONENT_RUNTIME), + Extension.create("json_name", Version.of(1, 2), Component.COMPONENT_RUNTIME), + Extension.create("select_optimization", Version.of(1, 1), Component.COMPONENT_RUNTIME), // Extensions not affecting the runtime are ignored. Extension.create("unknown", Version.of(2, 0), Component.COMPONENT_PARSER)); ProgramPlanner planner =