Commit graph

22236 commits

Author SHA1 Message Date
Jie Luo
bbc9dd9e8a Drop Python 3.9 support
Python 3.9 reached its official End-of-Life (EOL) on October 31, 2025
https://devguide.python.org/versions/

PiperOrigin-RevId: 854341311
2026-01-09 14:20:23 -08:00
Protobuf Team Bot
0262bd688a Auto-generate files after cl/854252074 2026-01-09 18:54:11 +00:00
Protobuf Team Bot
475c477c21 This CL uses fixed wire type for the following commonly used numeric types for
EDITION_UNSTABLE. Note that this CL is effectively no-op.
* int32, int64, uint32, uint64

It also removes the following now-redundant types.
* fixed32, fixed64, sfixed32, sfixed64, sint32, sint64.

The goal is to stop introducing new numeric types that use varint coding for
efficiency at the expense of larger wire data.

PiperOrigin-RevId: 854252074
2026-01-09 10:44:55 -08:00
Samuel Benzaquen
1060f8c751 Move the MessageSCCAnalyzer into the Options struct to avoid passing it
everywhere.

The option struct is already there to contain such objects.

PiperOrigin-RevId: 854248662
2026-01-09 10:37:08 -08:00
Protobuf Team Bot
e49deac5cc Auto-generate files after cl/854236148 2026-01-09 18:16:57 +00:00
Protobuf Team Bot
05317f94c1 Test bytes field rather than int32 for EditionUnstable conformance tests.
We plan to change protoc_minimal on how to interpret common numeric types like
int32, uint32, int64, uint64. Such change interacts badly with existing
conformance tests without much test coverage benefits.

This CL changes conformance tests to use bytes fields rather.

PiperOrigin-RevId: 854236148
2026-01-09 10:07:09 -08:00
Will Noble
312817ff8d Fix test proto visibility oversight (#24895)
This addresses an oversight from https://github.com/protocolbuffers/protobuf/issues/24508. The proto2 / 3 test protos are not visible from the test_protos directory.

This fixes `bazel build //conformance/test_protos/...`, which is currently broken.

Closes #24895

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/24895 from ouillie:main 815ec81c4f
PiperOrigin-RevId: 854211144
2026-01-09 08:54:40 -08:00
Protobuf Team Bot
282d6b867b Auto-generate files after cl/854155587 2026-01-09 14:01:33 +00:00
Protobuf Team Bot
0f3dd063c6 Add conformance test cases about handling of google.protobuf.Empty inside any Any in JSON.
As of today:
- GoProto and C# serialize google.protobuf.Empty-packed-into-Any with the `"value":{}` field set
- Only Go, C# and Swift accept that shape at parse time

In an attempt to make spec match reality, the public ProtoJSON documentation has now been clarified to match the common behavior that nearly all implementations have in practice.

Note that this conformance test added is only mandating that implementations:
1) Accept it without the `"value":{}` set
2) Serialize it without it set (by virtue of the round trip coming back to C++Proto in the test harness which does not accept it).

A test that confirms an implementation affirmatively rejects if the "value":{} is set is not added here; especially in the near term it is sensible for implementations like Go and C# to locally continue to accept that shape for backwards compatibility reasons within the same language, as long as it emits without it by default so that other languages can parse what it emits. For that reason, a test affirming a parse failure when it is present is not added to the conformance test suite failure today.

https://github.com/protocolbuffers/protobuf/issues/24445

PiperOrigin-RevId: 854155587
2026-01-09 05:52:22 -08:00
Protobuf Team Bot
eba53e8f17 Avoid collision name problems between a message named Xyz and a direct sibling enum named XyzView
We unfortuantely have no holistic startegy to avoid broken gencode from cross-type name collisions. We hold a high bar for special case mangling cross-type collisions, but this specific naming pattern combination is recommended by AIP 157.

Note that we will still break if the Xyz message and the XyzView enum are defined in separate .proto files but built in the same crate. It is very difficult for us to avoid that specific collision, so we are punting on it for now and only handling the case where the message and enum are defined in the same file. Especially when using blazel, we recommend one proto_library() per proto file, which would avoid that topic from being a concern.

PiperOrigin-RevId: 853935768
2026-01-08 16:59:54 -08:00
Protobuf Team Bot
0bc41927e9 Adds support for 3 modes for proto extension generation:
-   `class_based`: Legacy behavior
-   `migration`: Legacy behavior remains, and C functions added
-   `c_function`: All extensions and registries are generated as C functions only

This mitigates risks of collisions of generated *Root classe names, and reduces
binary overhead of proto extensions.

PiperOrigin-RevId: 853860971
2026-01-08 13:22:07 -08:00
Protobuf Team Bot
53729c7a1f Auto-generate files after cl/853822318 2026-01-08 19:46:44 +00:00
Mike Kruskal
7f431bb54a Remove PROTOBUF_CONSTEXPR to unconditionally use constexpr
#test-continuous

This was a legacy shim for C++11 and C++14 support, that's no longer needed.  It also seems to be causing potential issues for unsupported compilers, when we disable it.

PiperOrigin-RevId: 853822318
2026-01-08 11:37:29 -08:00
Protobuf Team Bot
ce5ff11bc8 Inline the generated Rust message Drop implementations
This allows the compiler to potentially optimize away unused message types more effectively, as demonstrated by the size reductions observed when unused messages are added in a test proto file.

PiperOrigin-RevId: 853529287
2026-01-07 20:44:59 -08:00
Protobuf Team Bot
733f179b39 Fix -Wdeprecated-declarations suppression on Windows
clang on Windows implements GNUC extensions, defines __clang__, but doesn't define __GNUC__, so one needs to handle both __clang__ and __GNUC__ cases. Fix this by using the existing PROTOBUF_IGNORE_DEPRECATION_* macros.

This upstreams (an improved version of) one of Chromium's patches: https://source.chromium.org/chromium/chromium/src/+/main:third_party/protobuf/patches/0049-deprecated-declarations-pragma.patch

PiperOrigin-RevId: 853514094
2026-01-07 19:56:17 -08:00
Mike Kruskal
97c979be6e Breaking change: remove deprecated flag for enabling MSVC support
With the path length limitations from Bazel fixed, we ended up reversing course on this plan.  We will continue to support MSVC and this flag hasn't done anything for a few releases.

PiperOrigin-RevId: 853482413
2026-01-07 17:57:26 -08:00
Protobuf Team Bot
64bc8721d9 Auto-generate files after PR #25161 2026-01-08 01:53:07 +00:00
Brent Shaffer
b01099d563 feat(php): support default values for editions/proto2 (#25161)
b/435022198

Closes #25161

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/25161 from bshaffer:php-fix-ignored-default-fields 16706c0a98
PiperOrigin-RevId: 853479507
2026-01-07 17:44:16 -08:00
Protobuf Team Bot
71cc97ce5a Add bounds checking to DeleteSubrange, create new helper, RuntimeAssertInBoundsGE, and modify LogIndexOutOfBoundsAndAbort to customize the message being logged.
PiperOrigin-RevId: 853478344
2026-01-07 17:39:39 -08:00
Jie Luo
c301c2ca28 Breaking Change: Remove deprecated UseDeprecatedLegacyJsonFieldConflicts()
https://protobuf.dev/news/2025-09-19/#cpp-remove-apis

PiperOrigin-RevId: 853477445
2026-01-07 17:35:56 -08:00
Sahin Yort
8c857c3a1c fix: cc_toolchain should prefer protoc when prebuilt flag is flipped. (#25168)
cc_toolchain now respects the prefer_prebuilt_protoc flag. When the flag is set to true, the toolchain uses the full protoc binary instead of protoc_minimal, enabling prebuilt protoc support.

Follow up to this is to have minimal protoc released as an artifact and use that.

Closes #25168

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/25168 from thesayyn:cc_toolchain_prebuilt 30451beb53
PiperOrigin-RevId: 853463775
2026-01-07 16:52:04 -08:00
Protobuf Team Bot
c404f03771 Move the location of linkage_monitor jar from Cloud Storage to Github releases.
PiperOrigin-RevId: 853440778
2026-01-07 15:43:18 -08:00
Protobuf Team Bot
5ea44d88fe Add @throws javadoc on setters/adders of open enums.
This documents that they may throw if UNSPECIFIED was provided.

Note that this conditional applies to legacy closed enums as well, not just open-enum-fields, since in legacy closed enums the underlying enum is open and will have an UNSPECIFIED value available that will still throw, though it will be somewhat more rare of a concern because `x.setX(y.getX())` can never throw if x and y are the same message type, it will still be a reachable exception if its a legacy closed field on `x` but an open field on `y`.

Fixes https://github.com/protocolbuffers/protobuf/issues/22829

PiperOrigin-RevId: 853401993
2026-01-07 14:02:37 -08:00
Sandy Zhang
5b19757b15 Fix MaybeRestartJavaMethod to actually pass / include the method name in the restarted Java gencode method.
PiperOrigin-RevId: 853373524
2026-01-07 12:45:00 -08:00
Protobuf Team Bot
6d5780ff3d Allow writing string to the end of internal buffer instead of enforcing spaceLeft().
PiperOrigin-RevId: 853279267
2026-01-07 08:49:27 -08:00
Marcin Kowalczyk
98654284be Optimize parsing packed repeated bool fields.
Check if each byte in the array is a valid representation for a bool,
i.e. 0 or 1. If so, skip varint parsing, and help the compiler with making
conversion to bool trivial.

PiperOrigin-RevId: 853089336
2026-01-06 22:46:20 -08:00
Protobuf Team Bot
1874f4101b Protobuf conformance: add test cases for protojson non-numeric int/float parsing
We got a bug report for Go Protobuf where users discovered that in Go Protobuf,
parsing does not fail despite trailing garbage after numbers:
related to https://github.com/golang/protobuf/issues/1678

Let’s add these cases to the conformace test suite to ensure consistent behavior
across the various Protobuf implementations.

PiperOrigin-RevId: 853056737
2026-01-06 21:03:09 -08:00
Protobuf Team Bot
1fb9da4690 Auto-generate files after cl/852971617 2026-01-07 00:15:14 +00:00
Mikita Belahlazau
4f076d951f Add metadata annotations for generated Python protobuf symbols.
The pyi generator now includes Kythe annotations for:
*   Extension field constants (e.g., `EXTENSION_FIELD`).
*   Field number constants (e.g., `STRING_FIELD_FIELD_NUMBER`).
*   `Create` methods in generated Stubby client classes.

These annotations allow the Python indexer to link these generated symbols back to their definitions in the `.proto` files.

PiperOrigin-RevId: 852971617
2026-01-06 16:05:56 -08:00
Protobuf Team Bot
9eb9b36e8a Check if ByteString is empty by using isEmpty() instead of == ByteString.EMPTY
PiperOrigin-RevId: 852852532
2026-01-06 11:02:46 -08:00
Protobuf Team Bot
2ec322ed57 Fix issue where BinaryToJson a Skip()'s failure on unknown fields was ignored instead of resulting in a parse failure.
This harmonizes the BinaryToJson behavior with wire_format.cc skip unknown: it still has the odd implication of truncating the length varint, but it will now correctly parse-fail if the length is larger than the remaining bytes (before it just skipped to the end of the buffer) and also parse-fail if the 32nd bit is set (which is viewed as a negative length by CodedInputStream and would have just continued parsing without skipping anything)

Fixes https://github.com/protocolbuffers/protobuf/issues/25092

PiperOrigin-RevId: 852791222
2026-01-06 08:33:35 -08:00
Protobuf Team Bot
262d725988 Auto-generate files after cl/852733884 2026-01-06 13:36:57 +00:00
Protobuf Team Bot
ae67a4c195 Internal version update.
PiperOrigin-RevId: 852733884
2026-01-06 05:27:44 -08:00
Protobuf Team Bot
439f2a5812 Automated Code Change
PiperOrigin-RevId: 852635614
2026-01-06 00:02:48 -08:00
Marcin Kowalczyk
bd7fe97e8c Internal change
PiperOrigin-RevId: 852518819
2026-01-05 17:28:03 -08:00
Marcin Kowalczyk
28178aeee1 Optimize parsing packed repeated varint fields:
* If counting varints revealed that each varint takes one byte, skip varint
  parsing. Idea by sbenza@.

* Do not check if all varints necessarily fit under the current capacity,
  which was done to skip counting varints. Counting varints is now useful
  also to check if each varint takes one byte, and it is now cheap enough
  to perform unconditionally.

  There were actually two capacity checks by mistake, and in the case of
  enough capacity we were doing a slower loop with Add instead of a faster
  loop with setting an element.

PiperOrigin-RevId: 852517269
2026-01-05 17:24:06 -08:00
tomas-molina
6a8c2aa314 Update options.md for Thermo Fisher Scientific (#24491)
Update options to support ranges for Thermo Fisher Scientific TEM grpc interfaces.

Closes #24491

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/24491 from tomas-molina:update_tfs_options c9c27bbdc0
PiperOrigin-RevId: 852445445
2026-01-05 14:04:06 -08:00
Protobuf Team Bot
3657ce3ba3 Allow unused return on various Protobuf methods.
This is only adding the annotation on cases that match standard idioms that return values can be ignored: like collections add/addAll/remove and Builders returning `this`

PiperOrigin-RevId: 852435246
2026-01-05 13:38:10 -08:00
Protobuf Team Bot
9849c1cb7f Fix unused utf_validity include in parse_context.h
Fixes https://github.com/protocolbuffers/protobuf/issues/24765

PiperOrigin-RevId: 852415902
2026-01-05 12:47:57 -08:00
Protobuf Team Bot
d69c2a7401 Auto-generate files after cl/852406706 2026-01-05 20:32:50 +00:00
Chris Kennelly
1a7e200aac Add nodiscard to generated APIs.
This covers two types of failures:
* Methods that are logically const and failure to consume the result indicates a bug
  (an unnecessary call, etc.)
* Methods that return significant errors (failure to parse, etc.) that should not be
  unintentionally ignored.

PiperOrigin-RevId: 852406706
2026-01-05 12:23:55 -08:00
Chris Kennelly
b05fef45b5 Reorder includes.
PiperOrigin-RevId: 852349546
2026-01-05 10:12:08 -08:00
Protobuf Team Bot
0f4ee5ecba Automated rollback of commit df04e01df5.
PiperOrigin-RevId: 852344735
2026-01-05 10:01:33 -08:00
Protobuf Team Bot
7400557a7d Try to avoid concat two bytes right away if two LazyFields contain different extension registries.
PiperOrigin-RevId: 852334989
2026-01-05 09:37:10 -08:00
Chris Kennelly
a70115f33f Breaking change: Add [[nodiscard]] to many APIs.
This covers two types of failures:
* Methods that are logically const and failure to consume the result indicates a bug
  (an unnecessary call, etc.)
* Methods that return significant errors (failure to parse, etc.) that should not be
  unintentionally ignored.

PiperOrigin-RevId: 852313694
2026-01-05 08:41:35 -08:00
Protobuf Team Bot
3acf23cce5 Abort on out of bounds accesses.
Previously out of bounds accesses would trigger undefined behavior.

PiperOrigin-RevId: 851463137
2026-01-02 15:44:08 -08:00
Sandy Zhang
7beda33399 Clean up dead dist_files targets.
PiperOrigin-RevId: 851412528
2026-01-02 12:19:11 -08:00
Kurt Alfred Kluever
443fef90a1 Mention the UTF-8 variants in the deprecation text of ByteString APIs.
PiperOrigin-RevId: 851339566
2026-01-02 07:44:04 -08:00
Protobuf Team Bot
0fa45b23bd Auto-generate files after cl/850517623 2025-12-30 23:04:15 +00:00
Joshua Haberman
00d838bb19 Make it a runtime flag whether we treat closed enums as open.
PiperOrigin-RevId: 850517623
2025-12-30 14:54:58 -08:00