Skip to content

Commit 8238439

Browse files
Add v34.0 breaking changes to the migration guide.
PiperOrigin-RevId: 866101933
1 parent e5f9c35 commit 8238439

1 file changed

Lines changed: 259 additions & 17 deletions

File tree

content/support/migration.md

Lines changed: 259 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,244 @@ aliases = "/programming-guides/migration/"
66
type = "docs"
77
+++
88

9+
## Changes in v34.0 {#v34}
10+
11+
The following is a list of the breaking changes made to versions of the
12+
libraries, and how to update your code to accommodate the changes.
13+
14+
This covers breaking changes announced in
15+
[News Announcements for v34.x](/news/2025-09-19) and
16+
[Release Notes for v34.0](https://github.com/protocolbuffers/protobuf/releases/tag/v34.0).
17+
18+
### Changes in C++ {#v34-cpp}
19+
20+
C++ bumped its major version to 7 with the 7.34.0 release. 6.33 is the final
21+
minor version release on 6.x.
22+
23+
#### Removal of Future Macros
24+
25+
The following macros, introduced for staged roll-out of breaking changes, were
26+
removed and their behavior is now the default:
27+
28+
* `PROTOBUF_FUTURE_RENAME_ADD_UNUSED_IMPORT`
29+
* `PROTOBUF_FUTURE_REMOVE_ADD_IGNORE_CRITERIA`
30+
* `PROTOBUF_FUTURE_STRING_VIEW_DESCRIPTOR_DATABASE`
31+
* `PROTOBUF_FUTURE_NO_RECURSIVE_MESSAGE_COPY`
32+
* `PROTOBUF_FUTURE_REMOVE_REPEATED_PTR_FIELD_ARENA_CONSTRUCTOR`
33+
* `PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR`
34+
* `PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR`
35+
36+
#### New RepeatedPtrField Layout {#cpp-repeatedptrfield-layout}
37+
38+
`RepeatedPtrField` were transitioned to a new internal element layout in which
39+
elements are stored in contiguous chunks of preallocated memory, similar to
40+
`std::deque`. This results in some changes to copy/move semantics of some APIs,
41+
and some `UnsafeArena` APIs may become functional equivalents of their
42+
arena-safe counterparts and be deprecated.
43+
44+
#### MSB Hardening Check on RepeatedField::Get and RepeatedPtrField::Get {#cpp-repeatedfield-get-hardening}
45+
46+
Protobufs were hardened against OOB errors by adding comprehensive bounds
47+
checking to repeated field accesses.
48+
49+
#### Remove Arena-enabled constructors from Repeated/Map Fields {#cpp-remove-arena-ctors}
50+
51+
The `RepeatedField(Arena*)`, `RepeatedPtrField(Arena*)`, and `Map(Arena*)`
52+
constructors were deleted.
53+
54+
#### Remove Deprecated APIs {#cpp-remove-apis}
55+
56+
We removed the following public runtime APIs.
57+
58+
##### AddUnusedImportTrackFile() and ClearUnusedImportTrackFiles()
59+
60+
**API:** `AddUnusedImportTrackFile()`, `ClearUnusedImportTrackFiles()`
61+
62+
**Replacement:** `AddDirectInputFile()` and `ClearDirectInputFiles()`
63+
64+
##### AddIgnoreCriteria from message differencer
65+
66+
`PROTOBUF_FUTURE_REMOVE_ADD_IGNORE_CRITERIA` was added for the breaking change.
67+
We removed the macro.
68+
69+
**API:** `AddIgnoreCriteria()`
70+
71+
**Replacement:** Wrap the raw pointer in a `unique_ptr`.
72+
73+
##### FieldDescriptor::has_optional_keyword()
74+
75+
**API:** `FieldDescriptor::has_optional_keyword()`
76+
77+
**Replacement:** `has_presence()`
78+
79+
##### FieldDescriptor::label()
80+
81+
**API:** `FieldDescriptor::label()`
82+
83+
**Replacement:** `is_repeated()` or `is_required()`
84+
85+
##### FieldDescriptor::is_optional()
86+
87+
**API:** `FieldDescriptor::is_optional()`
88+
89+
**Replacement:** `!is_required() && !is_repeated()`
90+
91+
##### UseDeprecatedLegacyJsonFieldConflicts()
92+
93+
**API:** `UseDeprecatedLegacyJsonFieldConflicts()`
94+
95+
**Replacement:** No replacement.
96+
97+
#### Stricter Name Length Limits {#cpp-name-limits}
98+
99+
The protobuf compiler enforces stricter limits on the length of symbol names,
100+
such as field names, to prevent potential issues. If the length of any field
101+
name is > 2^16, it generates an error.
102+
103+
#### Hide Private Generator Headers in CMake {#cpp-cmake-headers}
104+
105+
The protoc generator headers are no longer installed by CMake. This should not
106+
affect most users.
107+
108+
#### [[nodiscard]] on Logically Constant Operations {#cpp-nodiscard}
109+
110+
`[[nodiscard]]` was added to several logically constant protobuf APIs where
111+
failure to consume the returned value indicates a probable bug. This follows
112+
patterns used commonly in the C++ standard library.
113+
114+
### Changes in Python {#v34-python}
115+
116+
Python bumped its major version to 7 with the 7.34.0 release. 6.33 is the final
117+
minor version release on 6.x.
118+
119+
#### Dropped Python 3.9 Support
120+
121+
The minimum supported Python version is 3.10. Users should upgrade.
122+
123+
#### Relax Poison Pill Warnings
124+
125+
We relaxed the poison pills. No warnings or errors are raised for old generated
126+
files for 7.34.x.
127+
128+
#### Raise TypeError on Incorrect Conversion to Timestamp or Duration
129+
130+
We now raise a `TypeError` instead of an `AttributeError` when converting an
131+
incorrect type to a `Timestamp` or `Duration`.
132+
133+
#### Reject bool to enum and int field
134+
135+
We now reject setting `enum` or `int` fields with boolean values. The API raises
136+
an error instead of implicitly converting them.
137+
138+
#### Remove float_precision from json_format
139+
140+
We removed the deprecated `float_precision` option from the `json_format`
141+
serializer. This option does not exist in other ProtoJSON serializers and has
142+
confusing semantics.
143+
144+
#### Remove float_format/double_format from text_format
145+
146+
We removed the deprecated `float_format` and `double_format` options from
147+
`text_format`. These options are not available in other proto text format
148+
serializers.
149+
150+
#### Removed Deprecated APIs {#v34-php-remove-apis}
151+
152+
We removed the following public runtime APIs.
153+
154+
##### FieldDescriptor.label
155+
156+
**API:** `FieldDescriptor.label`
157+
158+
**Replacement:** `is_repeated()` or `is_required()`
159+
160+
### Changes in PHP {#v34-php}
161+
162+
PHP bumped its major version to 5 with the 5.34.0 release. 4.33 is the final
163+
minor version release on 4.x.
164+
165+
#### Dropped PHP 8.1 Support
166+
167+
The minimum supported PHP version is 8.2. Users should upgrade.
168+
169+
#### Removed Deprecated APIs {#v34-php-remove-apis}
170+
171+
We removed the following public runtime APIs.
172+
173+
##### FieldDescriptor getLabel
174+
175+
**API:** `FieldDescriptor getLabel`
176+
177+
**Replacement:** `isRepeated()` or `isRequired()`
178+
179+
##### Google\Protobuf\Field_Kind
180+
181+
**API:** `Google\Protobuf\Field_Kind`
182+
183+
**Replacement:** `Google\Protobuf\Field\Kind`
184+
185+
##### Google\Protobuf\Field_Cardinality
186+
187+
**API:** `Google\Protobuf\Field_Cardinality`
188+
189+
**Replacement:** `Google\Protobuf\Field\Cardinality`
190+
191+
##### Google\Protobuf\Internal\RepeatedField
192+
193+
**API:** `Google\Protobuf\Internal\RepeatedField`
194+
195+
**Replacement:** `Google\Protobuf\RepeatedField`
196+
197+
#### Fix Silent Ignoring of Default Values
198+
199+
The PHP runtime is fixed to honor default values on scalar fields in proto2 and
200+
editions, instead of silently ignoring them.
201+
202+
#### Type Checking Alignment
203+
204+
Type checking for pure-PHP and upb-PHP implementations are aligned. Notably,
205+
pure-PHP now rejects `null` for string fields, matching the behavior of upb-PHP.
206+
207+
### Changes in Objective-C {#v34-objc}
208+
209+
Objective-C bumped its major version to 5 with the 5.34.0 release. 4.33 is the
210+
final minor version release on 4.x.
211+
212+
#### Nullability Annotations
213+
214+
The nullability annotations for some `GPB*Dictionary` APIs were corrected to
215+
mark when APIs could return `nil`. This results in Swift code getting a Swift
216+
`Optional<T>`. For Objective-C callers, the annotation correction is less likely
217+
to have any impact on the source code.
218+
219+
#### Removed Deprecated API {#v34-objc-remove-apis}
220+
221+
We removed the following public runtime APIs.
222+
223+
##### GPBFieldDescriptor optional
224+
225+
**API:** -[`GPBFieldDescriptor optional`]
226+
227+
**Replacement:** `!required && fieldType == GPBFieldTypeSingle`
228+
229+
### Other Changes {#v34-other}
230+
231+
#### Dropped Bazel 7 Support
232+
233+
The minimum supported Bazel version is 8, which changes the default from
234+
WORKSPACE to Bzlmod. Users should upgrade to Bazel 8 or higher and migrate to
235+
Bzlmod.
236+
237+
#### Bazel: Remove deprecated ProtoInfo.transitive_imports
238+
239+
The deprecated `transitive_imports` field in `ProtoInfo` was removed. Users
240+
should migrate to `transitive_sources`.
241+
242+
#### Remove protobuf_allow_msvc flag and continue support Bazel+MSVC
243+
244+
Due to Bazel’s recent improvements on Windows, we now continue to support
245+
Bazel+MSVC. The `--define=protobuf_allow_msvc` flag was removed.
246+
9247
## Changes in v30.0 {#v30}
10248

11249
The following is a list of the breaking changes made to versions of the
@@ -15,7 +253,9 @@ This covers breaking changes announced in
15253
[News Announcements for v30.x](/news/v30) and
16254
[Release Notes for v30.0](https://github.com/protocolbuffers/protobuf/releases/tag/v30.0).
17255

18-
### Replaced CMake Submodules with Fetched Deps
256+
### Changes in C++ {#v30-cpp}
257+
258+
#### Replaced CMake Submodules with Fetched Deps
19259

20260
Previously, our default CMake behavior was to use Git submodules to grab pinned
21261
dependencies. Specifying `-Dprotobuf_ABSL_PROVIDER=package` would flip our CMake
@@ -38,7 +278,7 @@ behavior), you can call CMake with:
38278
cmake . -Dprotobuf_FORCE_FETCH_DEPENDENCIES=ON
39279
```
40280

41-
### string_view return type
281+
#### string_view return type
42282

43283
Return types are now `absl::string_view` for the following descriptor APIs,
44284
which opens up memory savings:
@@ -159,7 +399,7 @@ compatible with `absl::string_view`. Below are some common examples.
159399
See also [https://abseil.io/tips/1](https://abseil.io/tips/1) for general tips
160400
around using `absl::string_view`.
161401

162-
### Poison MSVC + Bazel
402+
#### Poison MSVC + Bazel
163403

164404
Bazel users on Windows should switch to using clang-cl by adding the following
165405
to their project, like in this
@@ -239,14 +479,14 @@ or by supplying the CMake command-line an MSVC generator. For example:
239479
cmake -G "Visual Studio 17 2022" -A Win64 .
240480
```
241481

242-
### ctype Removed from FieldDescriptor Options {#ctype-removed}
482+
#### ctype Removed from FieldDescriptor Options {#ctype-removed}
243483

244484
We stopped exposing the `ctype` from `FieldDescriptor` options. You can use the
245485
`FieldDescriptor::cpp_string_type()` API, added in the
246486
[v28 release](https://github.com/protocolbuffers/protobuf/releases/tag/v28.0),
247487
in its place.
248488

249-
### Modified Debug APIs to Redact Sensitive Fields {#debug-redaction}
489+
#### Modified Debug APIs to Redact Sensitive Fields {#debug-redaction}
250490

251491
The Protobuf C++ debug APIs (including Protobuf AbslStringify,
252492
`proto2::ShortFormat`, `proto2::Utf8Format`, `Message::DebugString`,
@@ -262,7 +502,7 @@ this does not redact sensitive fields and so should be used with caution.
262502
Read more about this in the
263503
[news article released December 4, 2024](/news/2024-12-04.md).
264504

265-
### Removed Deprecated APIs {#remove-deprecated}
505+
#### Removed Deprecated APIs {#v30-cpp-remove-apis}
266506

267507
We removed the following public runtime APIs, which have been marked deprecated
268508
(such as `ABSL_DEPRECATED`) for at least one minor or major release and that are
@@ -290,15 +530,15 @@ obsolete or replaced.
290530

291531
**Replacement:** `JsonPrintOptions`
292532

293-
### Dropped C++14 Support {#drop-cpp-14}
533+
#### Dropped C++14 Support {#drop-cpp-14}
294534

295535
This release dropped C++ 14 as the minimum supported version and raised it to
296536
17, as per the
297537
[Foundational C++ Support matrix](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md).
298538

299539
Users should upgrade to C++17.
300540

301-
### Introduced ASAN Poisoning After Clearing Oneof Messages on Arena
541+
#### Introduced ASAN Poisoning After Clearing Oneof Messages on Arena
302542

303543
This change added a hardening check that affects C++ protobufs using Arenas.
304544
Oneof messages allocated on the protobuf arena are now cleared in debug and
@@ -307,14 +547,14 @@ region will cause a crash in ASAN as a use-after-free error.
307547

308548
This implementation requires C++17.
309549

310-
### Dropped our C++ CocoaPods release
550+
#### Dropped our C++ CocoaPods release
311551

312552
We dropped our C++ CocoaPods release, which has been broken since v4.x.x. C++
313553
users should use our
314554
[GitHub release](https://github.com/protocolbuffers/protobuf/releases) directly
315555
instead.
316556

317-
### Changes in Python {#python}
557+
### Changes in Python {#v30-python}
318558

319559
Python bumped its major version from 5.29.x to 6.30.x.
320560

@@ -344,7 +584,7 @@ removed. It was replaced by the official `py_proto_library` which was moved to
344584
protobuf in `bazel/py_proto_library` in v29.x. This implementation was
345585
previously available in `rules_python` prior to v29.x.
346586

347-
#### Remove Deprecated APIs {#python-remove-apis}
587+
#### Remove Deprecated APIs {#v30-python-remove-apis}
348588

349589
We removed the following public runtime APIs, which had been marked deprecated
350590
for at least one minor or major release.
@@ -418,7 +658,7 @@ self.assertEqual('Bar', nested.__class__.__name__)
418658
self.assertEqual('Foo.Bar', nested.__class__.__qualname__) # It was 'Bar' before
419659
```
420660

421-
### Changes in Objective-C {#objc}
661+
### Changes in Objective-C {#v30-objc}
422662

423663
**This is the first breaking release for Objective-C**.
424664

@@ -468,7 +708,7 @@ the values for a given field number. The APIs for creating new fields are the
468708
We also deprecated `-[GPBMessage unknownFields]`. In its place, there are new
469709
APIs to extract and update the unknown fields of the message.
470710

471-
#### Removed Deprecated APIs {#objc-remove-apis}
711+
#### Removed Deprecated APIs {#v30-objc-remove-apis}
472712

473713
We removed the following public runtime APIs, which had been marked deprecated
474714
for at least one minor or major release.
@@ -524,7 +764,7 @@ which includes any unknown fields.
524764
and
525765
[-[`GPBMessage clearUnknownFields`]](https://github.com/protocolbuffers/protobuf/blob/224573d66a0cc958c76cb43d8b2eb3aa7cdb89f2/objectivec/GPBMessage.h#L497-L504C9)
526766

527-
#### Removed Deprecated Runtime APIs for Old Gencode {#objc-remove-apis-gencode}
767+
#### Removed Deprecated Runtime APIs for Old Gencode {#v30-objc-remove-apis-gencode}
528768

529769
This release removed deprecated runtime methods that supported the Objective-C
530770
gencode from before the 3.22.x release. The library also issues a log message at
@@ -555,20 +795,22 @@ allocDescriptorForName:valueNames:values:count:enumVerifier:extraTextFormatInfo:
555795

556796
**Replacement:** Regenerate with a current version of the library.
557797

558-
### Poison Pill Warnings {#poison}
798+
### Other Changes {#v30-other}
799+
800+
#### Poison Pill Warnings {#poison}
559801

560802
We updated poison pills to emit warnings for old gencode + new runtime
561803
combinations that work under the new rolling upgrade policy, but will break in
562804
the *next* major bump. For example, Python 4.x.x gencode should work against
563805
5.x.x runtime but warn of upcoming breakage against 6.x.x runtime.
564806

565-
### Changes to UTF-8 Enforcement in C# and Ruby {#utf-8-enforcement}
807+
#### Changes to UTF-8 Enforcement in C# and Ruby {#utf-8-enforcement}
566808

567809
We included a fix to make UTF-8 enforcement consistent across languages. Users
568810
with bad non-UTF8 data in string fields may see surfaced UTF-8 enforcement
569811
errors earlier.
570812

571-
### Ruby and PHP Errors in JSON Parsing
813+
#### Ruby and PHP Errors in JSON Parsing
572814

573815
We fixed non-conformance in JSON parsing of strings in numeric fields per the
574816
[JSON spec](https://protobuf.dev/programming-guides/json/).

0 commit comments

Comments
 (0)