Skip to content

Commit d057a33

Browse files
Protocol Buffer TeamLogofile
Protocol Buffer Team
authored andcommitted
This documentation change includes the following:
* Removes some internal-only content from the public version of `/best-practices/api.md` * Redirects links to content moved to the `/best-practices` directory * Adds `features.utf8_validation` to the code sample in the Editions overview topic * Adds a section about error handling in Go Opaque API PiperOrigin-RevId: 714026940 Change-Id: Ie852bbfe813dba8cddd96ee6897b8252ea992421
1 parent b0d0efc commit d057a33

File tree

11 files changed

+23
-36
lines changed

11 files changed

+23
-36
lines changed

content/best-practices/1-1-1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ weight = 105
44
linkTitle = "1-1-1 Best Practice"
55
description = "All proto definitions should have one top-level element and build target per file."
66
type = "docs"
7+
aliases = "/programming-guides/1-1-1"
78
+++
89

910
The 1-1-1 best practice is to keep every proto_library and .proto file as small

content/best-practices/api.md

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ title = "API Best Practices"
33
weight = 100
44
description = "A future-proof API is surprisingly hard to get right. The suggestions in this document make trade-offs to favor long-term, bug-free evolution."
55
type = "docs"
6+
aliases = "/programming-guides/api"
67
+++
78

89
Updated for proto3. Patches welcome!
910

1011
This doc is a complement to
11-
[Proto Best Practices](/programming-guides/dos-donts).
12-
It's not a prescription for Java/C++/Go and other APIs.
12+
[Proto Best Practices](/best-practices/dos-donts). It's
13+
not a prescription for Java/C++/Go and other APIs.
1314

1415
If you see a proto straying from these guidelines in a code review, point the
1516
author to this topic and help spread the word.
@@ -730,31 +731,6 @@ your service name, even if it is defined inside a specific package. For example,
730731
a service named `Watcher` is likely to cause problems; something like
731732
`MyProjectWatcher` would be better.
732733

733-
## Ensure Every RPC Specifies and Enforces a (Permissive) Deadline {#every-rpc-deadline}
734-
735-
By default, an RPC does not have a timeout. Since a request may tie up backend
736-
resources that are only released on completion, setting a default deadline that
737-
allows all well-behaving requests to finish is a good defensive practice. Not
738-
enforcing one has in the past caused
739-
severe problems for major services . RPC clients
740-
should still set a deadline on outgoing RPCs and will typically do so by default
741-
when they use standard frameworks. A deadline may and typically will be
742-
overwritten by a shorter deadline attached to a request.
743-
744-
Setting the `deadline` option clearly communicates the RPC
745-
deadline to your clients, and is respected and enforced by standard frameworks:
746-
747-
```proto
748-
rpc Foo(FooRequest) returns (FooResponse) {
749-
option deadline = x; // there is no globally good default
750-
}
751-
```
752-
753-
Choosing a deadline value will especially impact how your system acts under
754-
load. For existing services, it is critical to evaluate existing client behavior
755-
before enforcing new deadlines to avoid breaking clients (consult SRE). In some
756-
cases, it may not be possible to enforce a shorter deadline after the fact.
757-
758734
## Bound Request and Response Sizes {#bound-req-res-sizes}
759735

760736
Request and response sizes should be bounded.

content/best-practices/dos-donts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title = "Proto Best Practices"
33
weight = 90
44
description = "Shares vetted best practices for authoring Protocol Buffers."
55
type = "docs"
6+
aliases = "/programming-guides/dos-donts"
67
+++
78

89
Clients and servers are never updated at exactly the same time - even when you

content/editions/overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ edition = "2023";
127127
128128
package com.example;
129129
130+
option features.utf8_validation = NONE;
131+
130132
message Player {
131133
// fields have explicit presence, so no explicit setting needed
132134
string name = 1 [default = "N/A"];

content/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ Protocol buffers support many scalar value types, including integers that use
279279
both variable-length encoding and fixed sizes. You can also create your own
280280
composite data types by defining messages that are, themselves, data types that
281281
you can assign to a field. In addition to the simple and composite value types,
282-
several [common types](/programming-guides/dos-donts#common)
282+
several [common types](/best-practices/dos-donts#common)
283283
are published.
284284
285285
## History {#history}

content/programming-guides/editions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,8 @@ to store your protocol buffer messages, the changes that you can make in your
977977
proto definition are different. {{% /alert %}}
978978

979979
Check
980-
[Proto Best Practices](/programming-guides/dos-donts) and
981-
the following rules:
980+
[Proto Best Practices](/best-practices/dos-donts) and the
981+
following rules:
982982

983983
* Don't change the field numbers for any existing fields. "Changing" the field
984984
number is equivalent to deleting the field and adding a new field with the

content/programming-guides/proto2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,8 @@ to store your protocol buffer messages, the changes that you can make in your
10251025
proto definition are different. {{% /alert %}}
10261026

10271027
Check
1028-
[Proto Best Practices](/programming-guides/dos-donts) and
1029-
the following rules:
1028+
[Proto Best Practices](/best-practices/dos-donts) and the
1029+
following rules:
10301030

10311031
* Don't change the field numbers for any existing fields. "Changing" the field
10321032
number is equivalent to deleting the field and adding a new field with the

content/programming-guides/proto3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,8 @@ to store your protocol buffer messages, the changes that you can make in your
978978
proto definition are different. {{% /alert %}}
979979

980980
Check
981-
[Proto Best Practices](/programming-guides/dos-donts) and
982-
the following rules:
981+
[Proto Best Practices](/best-practices/dos-donts) and the
982+
following rules:
983983

984984
* Don't change the field numbers for any existing fields. "Changing" the field
985985
number is equivalent to deleting the field and adding a new field with the

content/programming-guides/serialization-not-canonical.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type = "docs"
77

88
<!--*
99
# Document freshness: For more information, see go/fresh-source.
10-
freshness: { owner: 'haberman' reviewed: '2024-02-05' }
10+
freshness: { owner: 'esrauch' reviewed: '2025-01-09' }
1111
*-->
1212

1313
Many people want a serialized proto to canonically represent the contents of

content/reference/go/opaque-faq.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ you need to migrate said file to editions first.
9090
1. Run your unit and integration tests, and then roll out to a staging
9191
environment.
9292

93+
## Are Errors Ignored with Lazy Decoding? {#lazydecodingerrors}
94+
95+
No.
96+
[`proto.Marshal`](https://pkg.go.dev/google.golang.org/protobuf/proto?tab=doc#Marshal)
97+
will always validate the wire format data, even when decoding is deferred until
98+
first access.
99+
93100
## Where Can I Ask Questions or Report Issues? {#questions}
94101

95102
If you found an issue with the `open2opaque` migration tool (such as incorrectly

content/reference/rust/rust-redaction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Use the standard `fmt::Debug` ("`{:?}`" in format strings) on Protobuf messages
1616
for human-readable strings for logging, error messages, exceptions, and similar
1717
use cases. The output of this debug info is not intended to be machine-readable
1818
(unlike `TextFormat` and `JSON` which are
19-
[not be used for debug output](/programming-guides/dos-donts#text-format-interchange)).
19+
[not be used for debug output](/best-practices/dos-donts#text-format-interchange)).
2020

2121
Using `fmt::Debug` enables redaction of some sensitive fields.
2222

0 commit comments

Comments
 (0)