1717import com .google .protobuf .ByteString ;
1818import com .google .protobuf .Descriptors ;
1919import com .google .protobuf .Message ;
20- import dev .cel .common .CelErrorCode ;
21- import dev .cel .common .CelRuntimeException ;
2220import dev .cel .common .types .CelType ;
2321import dev .cel .common .types .SimpleType ;
2422import dev .cel .runtime .CelEvaluationException ;
25- import dev .cel .runtime .CelRuntime . CelFunctionBinding ;
23+ import dev .cel .runtime .CelFunctionBinding ;
2624import java .util .ArrayList ;
2725import java .util .Arrays ;
2826import java .util .Collections ;
@@ -49,7 +47,6 @@ static List<CelFunctionBinding> create() {
4947 ArrayList <CelFunctionBinding > bindings = new ArrayList <>();
5048 bindings .addAll (
5149 Arrays .asList (
52- celBytesToString (),
5350 celGetField (),
5451 celFormat (),
5552 celStartsWithBytes (),
@@ -73,27 +70,6 @@ static List<CelFunctionBinding> create() {
7370 return Collections .unmodifiableList (bindings );
7471 }
7572
76- /**
77- * This implements that standard {@code bytes_to_string} function. We override it because the CEL
78- * library doesn't validate that the bytes are valid utf-8.
79- *
80- * <p>Workaround until <a href="https://github.com/google/cel-java/pull/717">cel-java issue
81- * 717</a> lands.
82- */
83- private static CelFunctionBinding celBytesToString () {
84- return CelFunctionBinding .from (
85- "bytes_to_string" ,
86- ByteString .class ,
87- v -> {
88- if (!v .isValidUtf8 ()) {
89- throw new CelRuntimeException (
90- new IllegalArgumentException ("invalid UTF-8 in bytes, cannot convert to string" ),
91- CelErrorCode .BAD_FORMAT );
92- }
93- return v .toStringUtf8 ();
94- });
95- }
96-
9773 /**
9874 * Creates a custom function overload for the "getField" operation.
9975 *
0 commit comments