Changes Announced on November 7, 2024

Changes announced for Protocol Buffers on November 7, 2024.

The following sections cover planned breaking changes in the v30 release, expected in 2025 Q1. Also included are some changes that aren’t breaking but may require action on your part. These are in addition to those mentioned in the News article from October 2.

These describe changes as we anticipate them being implemented, but due to the flexible nature of software some of these changes may not land or may vary from how they are described in this topic.

Introduce ASAN Poisoning After Clearing Oneof Messages on Arena

This change adds a hardening check that affects C++ protobufs using Arenas. Oneof messages allocated on the protobuf arena will now be cleared in debug and poisoned in ASAN mode. After calling clear, future attempts to use the memory region will cause a crash in ASAN as a use-after-free error.

This implementation requires C++17.

Python setdefault Behavior Change for Map Fields

Starting in v30, setdefault will be similar to dict for ScalarMap, except that both key and value must be set. setdefault will be rejected for MessageMaps.

Remove Deprecated py_proto_library Macro

The deprecated internal py_proto_library Bazel macro in protobuf.bzl will be removed in v30.x.

This should be replaced by the official py_proto_library which will be moved to protobuf in bazel/py_proto_library as of v29.x. This implementation was previously available in rules_python prior to v29.x.

Python Nested Message Class __qualname__ Contains the Outer Message Name

Python nested message class __qualname__ now contains the outer message name. Prior to v30, __qualname__ has the same result with __name__ for nested message, in that the outer message name was not included.

For example:

message Foo {
  message Bar {
    bool bool_field = 1;
  }
}
nested = test_pb2.Foo.Bar()
self.assertEqual('Bar', nested.__class__.__name__)
self.assertEqual('Foo.Bar', nested.__class__.__qualname__) # It was 'Bar' before

Dropping our C++ CocoaPods release

In v30, we will be dropping our C++ CocoaPods release, which has been broken since v4.x.x. C++ users should use our GitHub release directly instead.

Ruby and PHP Errors in JSON Parsing

v30 fixes non-conformance in JSON parsing of strings in numeric fields per the JSON spec.

This fix will not be accompanied by a major version bump, but Ruby and PHP will now raise errors for non-numeric strings (e.g. “”, “12abc”, “abc”) in numeric fields. v29.x will include a warning for these error cases.