Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Protobuf Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-protobuf-knowledge-patch-nevaberry-plugins)
---
name: protobuf-knowledge-patch
description: Protocol Buffers
version: "36.2"
license: MIT
metadata:
author: Nevaberry
---
# Protocol Buffers compatibility guidance
Load this skill when upgrading Protocol Buffers, migrating schema Editions,
adapting generated APIs, or diagnosing build and runtime compatibility changes.
Use the topic references for complete migration details and examples.
Announcement-derived guidance retains its planned status in the references.
## Reference index
| Reference | Topics |
| --- | --- |
| [Compatibility, builds, and releases](references/compatibility-builds-and-releases.md) | Generated-code guarantees, support windows, build requirements, CMake, Bazel, compiler output, packaging, shared parsing changes |
| [C++ runtime and generated APIs](references/cpp-runtime-and-generated-apis.md) | Removed APIs, string views, descriptors, arenas, containers, proxies, bounds checks, text, JSON, time, diagnostics |
| [Editions, schema, and descriptors](references/editions-schema-and-descriptors.md) | Naming, visibility, imports, limits, custom options, cardinality, JSON names, Go APIs, proto2 migration |
| [Java, C#, and Objective-C](references/java-csharp-and-objective-c.md) | Generated types, large enums, validation, serialization, unknown fields, extension accessors, Kotlin/Native names |
| [PHP, Ruby, and Rust](references/php-ruby-and-rust.md) | Runtime classes, scalar behavior, recursion, signatures, crate distribution, generated paths, traits, mutable messages |
| [Python runtime and generated APIs](references/python-runtime-and-generated-apis.md) | Dynamic classes, descriptors, assignments, maps, repeated fields, NumPy, buffers, serialization, threading |
## Compatibility before regeneration
Upgrade the runtime before regenerating bindings, including for patch releases:
the generator can use APIs added in the same release. The default policy lets
code generated by `V.x.y` run on runtimes from `V.x.y` through the end of major `V+1`.
Security fixes can require updating the runtime and regenerating together.
C++ and Rust require generated code and runtime versions to match exactly,
including the patch version. Rebuild C++ dependents when changing runtimes;
there is no ABI stability guarantee even across patch releases.
Protobuf supports a single runtime major per process; align transitive dependencies.
Python's guarantee published as of `6.32.0` covers existing bindings generated
by `3.20.0` or later through at least runtime `8.x.y`.
An older generated-code version can warn on the last runtime major supporting it.
## Breaking API changes and deprecations
### C++ ownership, descriptors, and containers
String-valued descriptor accessors such as `full_name()` return `absl::string_view`,
as do `MessageLite::GetTypeName()` and `UnknownField::length_delimited()`.
Remove `PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE` from build definitions.
Construct a `std::string` when owned storage is needed.
| Previous API | Migration |
| --- | --- |
| `Arena::CreateMessage` | `Arena::Create` |
| `Arena::GetArena(value)` | `value->GetArena()` |
| `JsonOptions` | `JsonPrintOptions` |
| `FieldDescriptor::label()` | `is_repeated()` or `is_required()` |
| `is_optional()` | `!is_required() && !is_repeated()` |
| `has_optional_keyword()` for presence | `has_presence()` |
| `PROTOBUF_CONSTEXPR` | `constexpr` |
Use `FieldDescriptor::cpp_string_type()` after descriptor options stop exposing
`ctype`. Drop `MutableRepeatedFieldRef<T>::Reserve()` calls. For callers of
`RepeatedPtrField::ClearedCount()`, migrate to arena allocation.
`Reflection::GetEnum()` and `Reflection::GetRepeatedEnum()` warn about deprecation;
use `GetEnumValue()` or `GetRepeatedEnumValue()` when only the number is needed.
Debug builds reject copying a source into its descendant with
`destination.CopyFrom(source)`. Make an independent source copy first.
Clearing an arena-allocated oneof message clears its contents in debug builds
and poisons its storage under AddressSanitizer; a retained pointer can trigger
a use-after-free error after clearing.
`ExtractSubrange()` and `DeleteSubrange()` check ranges at runtime;
`AddAlreadyReserved()` and `AddNAlreadyReserved()` check reserved capacity.
Bounds checks also cover `UnsafeArenaExtractSubrange()`, `ReleaseLast()`, and
`SwapElements()`. Call `ReleaseLast()` only on a nonempty field.
### Python dynamic classes and descriptor mutation
Use `message_factory.GetMessageClass(descriptor)` instead of
`reflection.MakeClass` or old `GetPrototype` and `CreatePrototype` methods on
`MessageFactory` and `SymbolDatabase`. For `reflection.ParseMessage`, parse
bytes using the returned class. Replace factory and symbol database
`GetMessages` methods with `message_factory.GetMessageClassesForFiles()`.
Treat `GetOptions()` results as read-only and copy the options message before
editing it. The release includes a future mutation warning and a `TypeError`
path for immutable scalar options in upb.
Scalar maps require both `setdefault` arguments, as in
`msg.counts.setdefault("hits", 0)`; message-valued maps reject `setdefault()`.
Before updating to Python 7.34, remove `float_precision` from `json_format`
serialization and `float_format` and `double_format` from `text_format` calls.
The v34 announcement plans rejection of boolean assignments to enum and integer
fields; explicitly convert intentional boolean-to-integer assignments and use
valid enum values. Wrong-type `Timestamp` and `Duration` conversions change
from `AttributeError` to `TypeError` in that announcement.
### Other runtime migrations
For Python's `FieldDescriptor.label`, use `is_repeated` or `is_required`;
for PHP's `FieldDescriptor::getLabel()`, use `isRepeated()` or `isRequired()`.
PHP removes `hasOptionalKeyword()`; use `hasPresence()` for presence.
The pure-PHP `CodedInputStream` removes `total_bytes_limit`; enforce any
application-specific payload byte limit before parsing.
Objective-C replaces `GPBUnknownFieldSet` with ordered `GPBUnknownFields`.
Extract with `initFromMessage:` and apply with
`mergeUnknownFields:extensionRegistry:error:`. Call `clearUnknownFields` first
when replacing unknown fields. Regenerate pre-3.22.x code for the 4.30 runtime.
Java removes the experimental `FieldOrder` enum. Generated `isInitialized()`
methods are deprecated where the generator can determine there are no required
fields to check. Standard generated Java code can run with the new runtime
without `sun.misc.Unsafe`; Lite runtime paths still use it.
Rust `*_opt()` accessors return standard `Option`; replace explicit
`protobuf::Optional` types and match on `Some(value)` and `None`.
Replace `ProxiedInMapValue` with `MapValue`; `f32` and `f64` no longer satisfy
the map-key bound. `RepeatedMutIter` drops iterator trait implementations;
replace `.rev()` traversal with a loop calling its inherent `next_back()`.
## Build migrations
CMake dependency resolution checks installed packages first and fetches pinned
versions for missing dependencies. Per-dependency provider options such as
`protobuf_ABSL_PROVIDER` were removed. To require local packages or always fetch:
```sh
cmake -S . -B build-local -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON
cmake -S . -B build-fetched -Dprotobuf_FORCE_FETCH_DEPENDENCIES=ON
```
The first requires local packages; the second always fetches pinned versions.
CMake omits Protobuf tests by default; enable them with `-Dprotobuf_BUILD_TESTS=ON`.
Bazel prefers prebuilt `protoc`; use
`--@protobuf//bazel/flags:prefer_prebuilt_protoc=false` to build it from source.
For proto toolchains, enable `--incompatible_enable_proto_toolchain_resolution`,
then use `register_toolchain()` or `--extra_toolchains`. Consult the build
reference for exact Starlark flag labels and the native-flag behavior in 35.0
versus 35.1. Use `ProtoInfo.transitive_sources` instead of
`ProtoInfo.transitive_imports`. Bazel 8 defaults to Bzlmod; migrate `WORKSPACE`
dependency declarations to `MODULE.bazel` when upgrading to v34.
Load public `py_proto_library` from `bazel/py_proto_library.bzl`.
`internal_py_proto_library` warns ahead of planned Q1 2027 breaking changes.
`protoc` warns about `cc_generic_services`, `java_generic_services`, and
`py_generic_services`; migrate using your RPC framework's compiler plugin.
## Schema and Editions migration
Edition 2024 removes `import weak`. Place `import option` after other imports;
option-message types remain unavailable for field declarations in the importer.
Bazel 8 or later supports `proto_library.option_deps` for these dependencies.
Edition 2024 defaults C++ `string_type` to `VIEW`; set
`features.(pb.cpp).string_type` to `STRING` to preserve previous accessors.
Its generated enum-name helpers default to `absl::string_view`; use
`features.(pb.cpp).enum_name_uses_string_view = false` with the features schema
imported to retain `const std::string&` at file or enum scope.
Edition 2024 generates top-level Java types in separate files by default and
replaces `java_multiple_files` with `nest_in_file_class`. Import the Java
features schema and set `nest_in_file_class = YES` on declarations that must
remain inside the file class. `large_enum` supports larger Java enums, but
callers must replace enum `switch` statements on those values with comparisons.
Edition 2026 is slated to default naming to `STYLE2026`: a field named `x`
cannot coexist with `has_x`, `set_x`, `get_x`, `clear_x`, or `x_value`, and
`descriptor` is forbidden as a field name. Apply `STYLE_LEGACY` to individual
declarations that need legacy names. See the schema reference for strict
visibility, its nested-enum wrapper exception, and earlier naming policies.
`PROTO_LIMITS2026` caps messages at 1,500 fields and 1,000 oneofs, oneofs at
1,200 fields, and enums at 1,700 values. Use `LEGACY_NO_EXPLICIT_LIMITS` on an
affected message, oneof, or enum when migrating oversized declarations.
`LEGACY_BEST_EFFORT` permits ambiguous JSON mappings on a message or enum;
those mappings can still yield unspecified runtime behavior.
## New APIs and parsing behavior
Use `Arena::UniquePtr<T>` and `Arena::Ptr<T>` for objects that may be on an
arena, keeping the arena alive while pointers to its objects are used.
C++ repeated-field proxies are opt-in through `features.(pb.cpp).repeated_type`
set to `PROXY`; `LEGACY` remains the Edition 2026 default. Shallow proxy copies
refer to the same repeated field. The C++ reference lists omitted APIs and
the `RepeatedFieldOrProxy` bridge for helpers shared with legacy callers.
Set `(pb.enumvalue.json).string` to customize enum JSON strings. C# enum aliases
sharing a number can serialize using a later alias's custom JSON name.
C# `WriteDelimitedTo()` accepts `IBufferWriter<byte>` and writes a varint length
prefix. Rust `push_default()` appends a repeated message and returns a mutable
handle. Python supports NumPy bindings and compatible buffer-protocol inputs
for repeated scalar fields; the upb runtime supports free-threaded CPython.
C++ debug-format APIs redact `debug_redact` fields and add a randomized prefix
that prevents parsing their output as TextFormat. Use `TextFormat` for messages
that must be serialized for later parsing. `TimeUtil::FromString()` fails on
out-of-range `Duration` or `Timestamp` strings; check its return value.
Java's strict `JsonFormat` parsing is opt-in. Java's sorted JSON map keys use natural
`String` order, comparing UTF-16 code units. PHP accepts optional binary
recursion limits in `mergeFromString()` and `serializeToString()`.
See the compatibility reference for nested-payload depth checks across runtimes.