Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bundle/src/main/java/dev/cel/bundle/CelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ public interface CelBuilder {
* provider will be used first before falling back to the built-in {@link
* dev.cel.common.values.ProtoMessageValueProvider} for resolving protobuf messages.
*
* <p>Note that {@link CelOptions#enableCelValue()} must be enabled or this method will be a
* no-op.
* <p>Note that this option is only supported for planner-based runtime.
*/
@CanIgnoreReturnValue
CelBuilder setValueProvider(CelValueProvider celValueProvider);
Expand Down
38 changes: 0 additions & 38 deletions bundle/src/test/java/dev/cel/bundle/CelImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,24 +556,6 @@ public void program_withVars() throws Exception {
assertThat(program.eval(ImmutableMap.of("variable", "hello"))).isEqualTo(true);
}

@Test
public void program_withCelValue() throws Exception {
Cel cel =
standardCelBuilderWithMacros()
.setOptions(CelOptions.current().enableCelValue(true).build())
.addDeclarations(
Decl.newBuilder()
.setName("variable")
.setIdent(IdentDecl.newBuilder().setType(CelProtoTypes.STRING))
.build())
.setResultType(SimpleType.BOOL)
.build();

CelRuntime.Program program = cel.createProgram(cel.compile("variable == 'hello'").getAst());

assertThat(program.eval(ImmutableMap.of("variable", "hello"))).isEqualTo(true);
}

@Test
public void program_withProtoVars() throws Exception {
Cel cel =
Expand Down Expand Up @@ -1419,26 +1401,6 @@ public void programAdvanceEvaluation_nestedSelect() throws Exception {
.isEqualTo(CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("com.google.a")));
}

@Test
public void programAdvanceEvaluation_nestedSelect_withCelValue() throws Exception {
Cel cel =
standardCelBuilderWithMacros()
.setOptions(
CelOptions.current().enableUnknownTracking(true).enableCelValue(true).build())
.addVar("com", MapType.create(SimpleType.STRING, SimpleType.DYN))
.addFunctionBindings()
.setResultType(SimpleType.BOOL)
.build();
CelRuntime.Program program = cel.createProgram(cel.compile("com.google.a || false").getAst());

assertThat(
program.advanceEvaluation(
UnknownContext.create(
fromMap(ImmutableMap.of()),
ImmutableList.of(CelAttributePattern.fromQualifiedIdentifier("com.google.a")))))
.isEqualTo(CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("com.google.a")));
}

@Test
public void programAdvanceEvaluation_argumentMergeErrorPriority() throws Exception {
Cel cel =
Expand Down
5 changes: 5 additions & 0 deletions common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ java_library(
exports = ["//common/src/main/java/dev/cel/common:container"],
)

cel_android_library(
name = "container_android",
exports = ["//common/src/main/java/dev/cel/common:container_android"],
)

java_library(
name = "proto_ast",
exports = ["//common/src/main/java/dev/cel/common:proto_ast"],
Expand Down
12 changes: 12 additions & 0 deletions common/exceptions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,15 @@ java_library(
# used_by_android
exports = ["//common/src/main/java/dev/cel/common/exceptions:iteration_budget_exceeded"],
)

java_library(
name = "duplicate_key",
# used_by_android
exports = ["//common/src/main/java/dev/cel/common/exceptions:duplicate_key"],
)

java_library(
name = "overload_not_found",
# used_by_android
exports = ["//common/src/main/java/dev/cel/common/exceptions:overload_not_found"],
)
12 changes: 12 additions & 0 deletions common/src/main/java/dev/cel/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,18 @@ java_library(
],
)

cel_android_library(
name = "container_android",
srcs = ["CelContainer.java"],
tags = [
],
deps = [
"//:auto_value",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven_android//:com_google_guava_guava",
],
)

java_library(
name = "operator",
srcs = ["Operator.java"],
Expand Down
14 changes: 0 additions & 14 deletions common/src/main/java/dev/cel/common/CelOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.auto.value.AutoValue;
import com.google.errorprone.annotations.CheckReturnValue;
import com.google.errorprone.annotations.Immutable;
import dev.cel.common.annotations.Beta;

/**
* Options to configure how the CEL parser, type-checker, and evaluator behave.
Expand Down Expand Up @@ -105,8 +104,6 @@ public enum ProtoUnsetFieldOptions {

public abstract boolean enableUnknownTracking();

public abstract boolean enableCelValue();

public abstract int comprehensionMaxIterations();

public abstract boolean evaluateCanonicalTypesToNativeValues();
Expand Down Expand Up @@ -162,7 +159,6 @@ public static Builder newBuilder() {
.errorOnDuplicateMapKeys(false)
.resolveTypeDependencies(true)
.enableUnknownTracking(false)
.enableCelValue(false)
.comprehensionMaxIterations(-1)
.unwrapWellKnownTypesOnFunctionDispatch(true)
.fromProtoUnsetFieldOption(ProtoUnsetFieldOptions.BIND_DEFAULT)
Expand Down Expand Up @@ -432,16 +428,6 @@ public abstract static class Builder {
*/
public abstract Builder enableUnknownTracking(boolean value);

/**
* Enables the usage of {@code CelValue} for the runtime. It is a native value representation of
* CEL that wraps Java native objects, and comes with extended capabilities, such as allowing
* value constructs not understood by CEL (ex: POJOs).
*
* <p>Warning: This option is experimental.
*/
@Beta
public abstract Builder enableCelValue(boolean value);

/**
* Limit the total number of iterations permitted within comprehension loops.
*
Expand Down
26 changes: 26 additions & 0 deletions common/src/main/java/dev/cel/common/exceptions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,29 @@ java_library(
"//common/annotations",
],
)

java_library(
name = "duplicate_key",
srcs = ["CelDuplicateKeyException.java"],
# used_by_android
tags = [
],
deps = [
"//common:error_codes",
"//common:runtime_exception",
"//common/annotations",
],
)

java_library(
name = "overload_not_found",
srcs = ["CelOverloadNotFoundException.java"],
# used_by_android
tags = [
],
deps = [
"//common:error_codes",
"//common:runtime_exception",
"//common/annotations",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cel.common.exceptions;

import dev.cel.common.CelErrorCode;
import dev.cel.common.CelRuntimeException;
import dev.cel.common.annotations.Internal;

/** Indicates an attempt to create a map using duplicate keys. */
@Internal
public final class CelDuplicateKeyException extends CelRuntimeException {

public static CelDuplicateKeyException of(Object key) {
return new CelDuplicateKeyException(String.format("duplicate map key [%s]", key));
}

private CelDuplicateKeyException(String message) {
super(message, CelErrorCode.DUPLICATE_ATTRIBUTE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cel.common.exceptions;

import dev.cel.common.CelErrorCode;
import dev.cel.common.CelRuntimeException;
import dev.cel.common.annotations.Internal;
import java.util.Collection;
import java.util.Collections;

/** Indicates that a matching overload could not be found during function dispatch. */
@Internal
public final class CelOverloadNotFoundException extends CelRuntimeException {

public CelOverloadNotFoundException(String functionName) {
this(functionName, Collections.emptyList());
}

public CelOverloadNotFoundException(String functionName, Collection<String> overloadIds) {
super(formatErrorMessage(functionName, overloadIds), CelErrorCode.OVERLOAD_NOT_FOUND);
}

private static String formatErrorMessage(String functionName, Collection<String> overloadIds) {
StringBuilder sb = new StringBuilder();
sb.append("No matching overload for function '").append(functionName).append("'.");
if (!overloadIds.isEmpty()) {
sb.append(" Overload candidates: ").append(String.join(", ", overloadIds));
}

return sb.toString();
}
}
40 changes: 40 additions & 0 deletions common/src/main/java/dev/cel/common/types/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,32 @@ java_library(
],
)

java_library(
name = "message_lite_type_provider",
srcs = [
"ProtoMessageLiteTypeProvider.java",
],
tags = [
],
deps = [
"//common/types",
"//common/types:type_providers",
"//protobuf:cel_lite_descriptor",
"@maven//:com_google_guava_guava",
],
)

cel_android_library(
name = "message_lite_type_provider_android",
srcs = [
"ProtoMessageLiteTypeProvider.java",
],
tags = [
],
deps = [
],
)

java_library(
name = "default_type_provider",
srcs = [
Expand All @@ -197,6 +223,20 @@ java_library(
],
)

cel_android_library(
name = "default_type_provider_android",
srcs = [
"DefaultTypeProvider.java",
],
tags = [
],
deps = [
"//common/types:type_providers_android",
"//common/types:types_android",
"@maven_android//:com_google_guava_guava",
],
)

cel_android_library(
name = "cel_types_android",
srcs = ["CelTypes.java"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.Immutable;
import java.util.Optional;

/** {@code DefaultTypeProvider} is a registry of common CEL types. */
@Immutable
public class DefaultTypeProvider implements CelTypeProvider {

private static final DefaultTypeProvider INSTANCE = new DefaultTypeProvider();
Expand Down
Loading
Loading