Skip to content

Commit b6087da

Browse files
convert '%s' use to %q for error handling in EvaluateString
Signed-off-by: kathleen french <[email protected]>
1 parent ce34e2d commit b6087da

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

runtime/cel/expression.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ func (e *Expression) EvaluateBoolean(ctx context.Context, data map[string]any) (
141141
func (e *Expression) EvaluateString(ctx context.Context, data map[string]any) (string, error) {
142142
val, _, err := e.prog.ContextEval(ctx, data)
143143
if err != nil {
144-
return "", fmt.Errorf("failed to evaluate the CEL expression '%s': %w", e.expr, err)
144+
return "", fmt.Errorf("failed to evaluate the CEL expression %q: %w", e.expr, err)
145145
}
146146
result, ok := val.(types.String)
147147
if !ok {
148-
return "", fmt.Errorf("failed to evaluate CEL expression as string: '%s'", e.expr)
148+
return "", fmt.Errorf("failed to evaluate CEL expression as string: %q", e.expr)
149149
}
150150
return string(result), nil
151151
}

runtime/cel/expression_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func TestExpression_EvaluateString(t *testing.T) {
233233
name: "non-existent field",
234234
expr: "foo",
235235
data: map[string]any{},
236-
err: "failed to evaluate the CEL expression 'foo': no such attribute(s): foo",
236+
err: `failed to evaluate the CEL expression "foo": no such attribute(s): foo`,
237237
},
238238
{
239239
name: "string field",
@@ -245,7 +245,7 @@ func TestExpression_EvaluateString(t *testing.T) {
245245
name: "non-string field",
246246
expr: "foo",
247247
data: map[string]any{"foo": 123},
248-
err: "failed to evaluate CEL expression as string: 'foo'",
248+
err: `failed to evaluate CEL expression as string: "foo"`,
249249
},
250250
{
251251
name: "nested string field",
@@ -336,7 +336,7 @@ func TestExpression_EvaluateString(t *testing.T) {
336336
data: map[string]any{
337337
"foo": map[string]any{"bar": "hello-world-testing-123"},
338338
},
339-
err: "failed to evaluate CEL expression as string: 'foo.bar.split('-').first()'",
339+
err: `failed to evaluate CEL expression as string: "foo.bar.split('-').first()"`,
340340
},
341341
} {
342342
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)