I’m pretty sure that since 2 GiB is the maximum value an int32 could carry, that is where the requirement is coming from. It’s entirely possible that it is not actually enforced across the whole ecosystem, but is essentially enforced by “if you exceed this boundary, some code will not work with your protobuf.”
Like, for instance, it is impossible for a 32-bit Golang implementation do deal with more than 2 GiB data in a single slice. (Since the length of the slice is stored as a 32-bit signed integer.) Am Do., 3. Juli 2025 um 08:21 Uhr schrieb 'Somak Dutta' via Protocol Buffers <[email protected]>: > Hello, > > From https://protobuf.dev/programming-guides/proto-limits/ i understand > across all ecosystems > > Any proto in serialized form must be <2GiB, as that is the maximum size > supported by all implementations. It’s recommended to bound request and > response sizes. > > However wanted to check where exactly is the limitation set up, > specifically in protobuf-java library. > > I can see safe checks in only message_lite.cc files , but i dont think > this would be reflected across ecosystems? > > if (size > INT_MAX) { > GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << size; > return false; > } > > Regards > > *Confidentiality Notice: This email and any attachments are confidential > and intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error, please notify the > sender immediately and delete it from your system. Unauthorized use, > disclosure, or copying of this email or its contents is strictly > prohibited.* > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/protobuf/e0d724d8-2a45-4ef1-aaac-c3e6d1077306n%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/e0d724d8-2a45-4ef1-aaac-c3e6d1077306n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/protobuf/CAOF_i%2BWX%2BvotRoMd_nAhKx_TZqTNFQfmPXDV-GLdWL3gFasNig%40mail.gmail.com.
