Skip to content

Commit

Permalink
Improve error messages for Value type casting errors.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 698874247
  • Loading branch information
CEL Dev Team authored and copybara-github committed Nov 21, 2024
1 parent d50f3d3 commit 241c9dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions eval/public/structs/proto_message_type_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ absl::Status ProtoMessageTypeAdapter::SetField(
const CelMap* cel_map;
CEL_RETURN_IF_ERROR(ValidateSetFieldOp(
value.GetValue<const CelMap*>(&cel_map) && cel_map != nullptr,
field->name(), "value is not CelMap"));
field->name(),
absl::StrCat("value is not CelMap - value is ",
CelValue::TypeName(value.type()))));

auto entry_descriptor = field->message_type();

Expand Down Expand Up @@ -598,7 +600,9 @@ absl::Status ProtoMessageTypeAdapter::SetField(
const CelList* cel_list;
CEL_RETURN_IF_ERROR(ValidateSetFieldOp(
value.GetValue<const CelList*>(&cel_list) && cel_list != nullptr,
field->name(), "expected CelList value"));
field->name(),
absl::StrCat("expected CelList value - value is",
CelValue::TypeName(value.type()))));

for (int i = 0; i < cel_list->size(); i++) {
CEL_RETURN_IF_ERROR(internal::AddValueToRepeatedField(
Expand Down

0 comments on commit 241c9dd

Please sign in to comment.