Skip to content
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
15 changes: 0 additions & 15 deletions source/common/protobuf/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,6 @@ class UnexpectedFieldProtoVisitor : public ProtobufMessage::ConstProtoVisitor {

// If this field is deprecated, warn or throw an error.
if (field.options().deprecated()) {
if (absl::StartsWith(field.name(), "hidden_envoy_deprecated_")) {
// The field was marked as hidden_envoy_deprecated and an error must be thrown,
// unless it is part of an explicit test that needs access to the deprecated field
// when we enable runtime deprecation override to allow point field overrides for tests.
if (!runtime_ ||
!runtime_->snapshot().deprecatedFeatureEnabled(
absl::StrCat("envoy.deprecated_features:", field.full_name()), false)) {
const std::string fatal_error = absl::StrCat(
"Illegal use of hidden_envoy_deprecated_ V2 field '", field.full_name(),
"' from file ", filename,
" while using the latest V3 configuration. This field has been removed from the "
"current Envoy API. Please see " ENVOY_DOC_URL_VERSION_HISTORY " for details.");
throw ProtoValidationException(fatal_error, message);
}
}
const std::string warning =
absl::StrCat("Using {}deprecated option '", field.full_name(), "' from file ", filename,
". This configuration will be removed from "
Expand Down
45 changes: 0 additions & 45 deletions test/common/protobuf/utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1956,51 +1956,6 @@ TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(FatalEnumGlobalOverride)) {
checkForDeprecation(base));
}

// Verify that direct use of a hidden_envoy_deprecated field fails, but upgrade
// succeeds
TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(ManualDeprecatedFieldAddition)) {
// Create a base message and insert a deprecated field. When upgrading the
// deprecated field should be set as deprecated, and a warning should be logged
envoy::test::deprecation_test::Base base_should_warn =
TestUtility::parseYaml<envoy::test::deprecation_test::Base>(R"EOF(
not_deprecated: field1
is_deprecated: hidden_field1
not_deprecated_message:
inner_not_deprecated: subfield1
repeated_message:
- inner_not_deprecated: subfield2
)EOF");

// Non-fatal checks for a deprecated field should log rather than throw an exception.
EXPECT_LOG_CONTAINS("warning",
"Using deprecated option 'envoy.test.deprecation_test.Base.is_deprecated'",
checkForDeprecation(base_should_warn));
EXPECT_EQ(1, runtime_deprecated_feature_use_.value());
EXPECT_EQ(1, deprecated_feature_seen_since_process_start_.value());

// Create an upgraded message and insert a deprecated field. This is a bypass
// of the upgrading procedure validation, and should fail
envoy::test::deprecation_test::UpgradedBase base_should_fail =
TestUtility::parseYaml<envoy::test::deprecation_test::UpgradedBase>(R"EOF(
not_deprecated: field1
hidden_envoy_deprecated_is_deprecated: hidden_field1
not_deprecated_message:
inner_not_deprecated: subfield1
repeated_message:
- inner_not_deprecated: subfield2
)EOF");

EXPECT_THROW_WITH_REGEX(
MessageUtil::checkForUnexpectedFields(base_should_fail,
ProtobufMessage::getStrictValidationVisitor()),
ProtoValidationException,
"Illegal use of hidden_envoy_deprecated_ V2 field "
"'envoy.test.deprecation_test.UpgradedBase.hidden_envoy_deprecated_is_deprecated'");
// The config will be rejected, so the feature will not be used.
EXPECT_EQ(1, runtime_deprecated_feature_use_.value());
EXPECT_EQ(1, deprecated_feature_seen_since_process_start_.value());
}

class TimestampUtilTest : public testing::Test, public ::testing::WithParamInterface<int64_t> {};

TEST_P(TimestampUtilTest, SystemClockToTimestampTest) {
Expand Down
4 changes: 0 additions & 4 deletions tools/type_whisperer/api_type_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ absl::optional<TypeInformation> ApiTypeDb::getLatestTypeInformation(const std::s
if (value->options().HasExtension(udpa::annotations::enum_value_migrate)) {
result->renames_[value->name()] =
value->options().GetExtension(udpa::annotations::enum_value_migrate).rename();
} else if (value->options().deprecated()) {
result->renames_[value->name()] = "hidden_envoy_deprecated_" + value->name();
}
}
return result;
Expand All @@ -98,8 +96,6 @@ absl::optional<TypeInformation> ApiTypeDb::getLatestTypeInformation(const std::s
if (field->options().HasExtension(udpa::annotations::field_migrate)) {
result->renames_[field->name()] =
field->options().GetExtension(udpa::annotations::field_migrate).rename();
} else if (field->options().deprecated()) {
result->renames_[field->name()] = "hidden_envoy_deprecated_" + field->name();
}
}
return result;
Expand Down