Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder proto validation error message #38089

Merged
merged 2 commits into from
Jan 21, 2025
Merged
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
8 changes: 4 additions & 4 deletions source/common/protobuf/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ void ProtoExceptionUtil::throwMissingFieldException(const std::string& field_nam

void ProtoExceptionUtil::throwProtoValidationException(const std::string& validation_error,
const Protobuf::Message& message) {
std::string error = fmt::format("Proto constraint validation failed ({}): {}", validation_error,
message.DebugString());
std::string error = fmt::format("{}: Proto constraint validation failed ({})",
message.DebugString(), validation_error);
throwEnvoyExceptionOrPanic(error);
}

Expand Down Expand Up @@ -429,8 +429,8 @@ class PgvCheckVisitor : public ProtobufMessage::ConstProtoVisitor {
// at which PGV would have stopped because it does not itself check within Any messages.
if (was_any_or_top_level &&
!pgv::BaseValidator::AbstractCheckMessage(*reflectable_message, &err)) {
std::string error = fmt::format("Proto constraint validation failed ({}): {}", err,
reflectable_message->DebugString());
std::string error = fmt::format("{}: Proto constraint validation failed ({})",
reflectable_message->DebugString(), err);
return absl::InvalidArgumentError(error);
}
return absl::OkStatus();
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/string_matcher/lua/lua_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ TEST(LuaStringMatcher, NoCode) {

LuaStringMatcherFactory factory;
::envoy::extensions::string_matcher::lua::v3::Lua empty_config;
EXPECT_THROW_WITH_MESSAGE(
EXPECT_THROW_WITH_REGEX(
factory.createStringMatcher(empty_config, context), EnvoyException,
"Proto constraint validation failed (LuaValidationError.SourceCode: value is required): ");
"Proto constraint validation failed.*LuaValidationError.SourceCode: value is required");

empty_config.mutable_source_code()->set_inline_string("");
EXPECT_THROW_WITH_MESSAGE(factory.createStringMatcher(empty_config, context), EnvoyException,
Expand Down
Loading