Skip to content

Commit 9524a9e

Browse files
authored
feat: updates to several AIPs (#1562)
* feat(AIP-180): add string length change guidance * fix(AIP-126): allow UNKNOWN to be prefixed * feat(AIP-157): allow View use in other methods * fix(AIP-160): clarify top-level field HAS behavior * feat(AIP-180): add format change guidance * address feedback on aip-180 * address feedback on aip-160 * remove extra line in aip-180 * remove string size comment guidance
1 parent 1a0ff77 commit 9524a9e

6 files changed

Lines changed: 84 additions & 6 deletions

File tree

aip/general/0126.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ message Book {
5454
followed by the suffix `_UNSPECIFIED`.
5555
- An exception to this rule is if there is a clearly useful zero value. In
5656
particular, if an enum needs to present an `UNKNOWN`, it is usually clearer
57-
and more useful for it to be a zero value rather than having both.
57+
and more useful for it to be a zero value rather than having both. The
58+
`UNKNOWN` value **may** be prefixed by the enum name as is typical for
59+
avoiding enum value name collisions.
5860
- Enums which will only be used in a single message **should** be nested within that message.
5961
In this case, the enum **should** be declared immediately before it is used.
6062
- The non-zero values of such a nested enum definition **should not** be prefixed by the name
@@ -113,3 +115,7 @@ choice (although `google.protobuf.BoolValue` is also available).
113115
[aip-216]: ./0216.md
114116
[bcp-47]: https://en.wikipedia.org/wiki/IETF_language_tag
115117
[media types]: https://en.wikipedia.org/wiki/Media_type
118+
119+
## Changelog
120+
121+
- **2025-10-03**: Added prefixing guidance for `UNKNOWN` value exception.

aip/general/0133.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ rpc CreateBook(CreateBookRequest) returns (Book) {
4343
`CreateBookResponse`.
4444
- The response **should** include the fully-populated resource, and **must**
4545
include any fields that were provided unless they are input only (see
46-
[AIP-203][]).
46+
[AIP-203][]) or there is a reason to return a partial response (see
47+
[AIP-157][]).
4748
- If the create RPC is [long-running](#long-running-create), the response
4849
message **must** be a `google.longrunning.Operation` which resolves to the
4950
resource itself.
@@ -219,6 +220,7 @@ name and use it in references from other resources.
219220

220221
## Changelog
221222

223+
- **2025-10-03**: Allow use of partial responses via AIP-157.
222224
- **2023-10-20**: Clarify that {resource}_id is only required for management plane resources.
223225
- **2023-08-24**: Adding consistency requirement.
224226
- **2023-05-11**: Changing guidance around resource_id to a must.

aip/general/0134.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ rpc UpdateBook(UpdateBookRequest) returns (Book) {
4343
`UpdateBookResponse`.)
4444
- The response **should** include the fully-populated resource, and **must**
4545
include any fields that were sent and included in the update mask unless
46-
they are input only (see AIP-203).
46+
they are input only (see AIP-203) or there is a reason to return a partial
47+
response (see [AIP-157][]).
4748
- If the update RPC is [long-running](#long-running-update), the response
4849
message **must** be a `google.longrunning.Operation` which resolves to the
4950
resource itself.
@@ -302,6 +303,7 @@ does not exist, the service **must** error with `NOT_FOUND` (HTTP 404) unless
302303

303304
## Changelog
304305

306+
- **2025-10-03**: Allow use of partial responses via AIP-157.
305307
- **2024-12-03**: Add caveats to usage of full replacement `update_mask`.
306308
- **2024-03-14**: Make `update_mask` optional field_behaviour guidance a **must**.
307309
- **2023-08-26**: Adding consistency requirement.

aip/general/0157.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ enum BookView {
6161
- The enum **should** at minimum have values named `BASIC` and `FULL` (although
6262
it **may** have values other than these).
6363
- The `UNSPECIFIED` value **must** be valid (not an error), and the API
64-
**must** document what the unspecified value will do).
64+
**must** document what the unspecified value will do.
6565
- For List RPCs, the effective default value **should** be `BASIC`.
66-
- For Get RPCs, the effective default value **should** be either `BASIC` or
67-
`FULL`.
66+
- For the following RPC types, the effective default value **should** be
67+
either `BASIC` or `FULL`:
68+
- Get
69+
- Create
70+
- Update
71+
- Soft Delete
72+
- Custom Method
6873
- The enum **should** be defined at the top level of the proto file (as it is
6974
likely to be needed in multiple requests, e.g. both `Get` and `List`). See
7075
[AIP-126][] for more guidance on top-level enumerations.
@@ -76,6 +81,11 @@ enum BookView {
7681
conflict. In this situation, the service **should** nest the view enum within
7782
the individual resource.
7883

84+
**Note:** Having a partial response be the default of standard methods can
85+
degrade the effectiveness of declarative clients. Providing a mechanism to
86+
request the full resource be populated in the response, like this View
87+
pattern, is preferred if partial responses are deemed necessary.
88+
7989
### Read masks as a request field
8090

8191
**Warning:** Read mask as a single, explicit field on the request message is
@@ -107,6 +117,8 @@ potential point of conflict for the client or service.
107117

108118
## Changelog
109119

120+
- **2025-10-03**: Added default view guidance for other RPC types, and
121+
declarative client warning.
110122
- **2025-06-16**: Reinstate read mask guidance as historical/external reference.
111123
- **2023-05-09**: Fix top-level enum example and link to AIP-126.
112124
- **2022-03-14:** Updated guidance on default value and how to specify a read mask.

aip/general/0160.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ There are two slight distinctions when parsing messages:
183183
implementations **may** choose to support automatic conversion between camel
184184
case and snake case.
185185

186+
For all aforementioned types, simply checking for the presence of a top-level
187+
resource field is possible with the `*` value:
188+
189+
| Example | Meaning |
190+
| ---------- | ---------------------------------------- |
191+
| `r:*` | True if `repeated` field `r` is present. |
192+
| `p:*` | True if `map` field `p` is present. |
193+
| `m:*` | True if `message` field `m` is present. |
194+
195+
**Note:** For `map` and `repeated` fields, there is no semantic difference
196+
between an unset field and "set with empty value" - they both resolve to "not
197+
present".
198+
186199
### Functions
187200

188201
The filtering language supports a function call syntax in order to support
@@ -231,5 +244,6 @@ Schematic validation refers, but is not limited to, the following:
231244

232245
## Changelog
233246

247+
- **2025-10-03**: Clarify top-level field has operator behavior.
234248
- **2025-01-07**: Clarify behavior for unset field in traversal operator chain.
235249
- **2024-12-11**: Move non-compliant filter guidance to Validation section.

aip/general/0180.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ However, keep the following guidelines in mind when doing this:
6464
resources.
6565
- Any field being populated by clients **must** have a default behavior
6666
matching the behavior before the field was introduced.
67+
- This can be tricky to do in some cases. For example, adding pagination
68+
after the fact where previously all items were returned (i.e. `page_size`
69+
is infinite, which is not advised). If the default for the new `page_size`
70+
field is _less_ than what was previously returned, older clients will
71+
incorrectly assume all results were returned.
6772
- Any field previously populated by the server **must** continue to be
6873
populated, even if it introduces redundancy.
6974
- For enum values specifically, be aware that it is possible that user code
@@ -113,6 +118,15 @@ Existing fields and messages **must not** have their type changed, even if the
113118
new type is wire-compatible, because type changes alter generated code in a
114119
breaking way.
115120

121+
### Changing string length
122+
123+
APIs **should** avoid increasing the upper bound for the size or limit (if
124+
accepted as input) of `string` fields. APIs **should** treat expected size upper
125+
bound increases as incompatible changes (see [Changing resource names]
126+
(#changing-resource-names) as an example). APIs **may** pad out values with
127+
filler characters if reserving a consistent size is necessary, but this **must**
128+
be documented if done.
129+
116130
### Changing resource names
117131

118132
A resource **must not** change its [name][aip-122].
@@ -146,6 +160,15 @@ code, as such changes will be seen as breaking by those users.
146160
whether a proposed change is likely to break users, and an expansive reading of
147161
this guidance could ostensibly prevent _any_ change (which is not the intent).
148162

163+
#### Changing value format or construction
164+
165+
APIs **must not** change the expected format or algorithm used to construct the
166+
value of an existing field - even if the field is `OUTPUT_ONLY` and populated by
167+
the API service - within an API version. Doing so requires a new API version.
168+
169+
For example, changing the format of a field `ip_address` conforming to IPv4
170+
format to instead contain IPv6 values is a breaking change.
171+
149172
#### Default values must not change
150173

151174
Default values are the values set by servers for resources when they are not
@@ -245,8 +268,27 @@ version.
245268
- For compatibility around field presence changes, see [AIP-149][].
246269
- For compatibility around resource types, see [AIP-123][].
247270

271+
## Rationale
272+
273+
### Risk of string length changes
274+
275+
End users may store resource properties, like the `name`, in a dedicated
276+
database column with a limited length. If the service starts returning values
277+
for the `name` that are twice the originally documented/observed length, this
278+
may unexpectedly break the customer's database. Furthermore, string properties
279+
that appear in URLs (including query parameters) are especially likely to have
280+
client-side limits, making them more sensitive to length changes.
281+
282+
### Risk of changing value format or construction
283+
284+
Customers often depend on the format or algorithmic construction of a field for
285+
client-side parsing, hashing, or database table construction. Changing it in
286+
an existing field could break that client-side consumption.
287+
248288
## Changelog
249289

290+
- **2025-10-21**: Added guidance for string length changes, changing formats,
291+
and an example for carefully adding components.
250292
- **2024-08-07**: Added reference to resource type compatibility.
251293
- **2024-06-05**: Added reference to field presence compatibility.
252294
- **2023-07-26**: Added reference to field behavior compatibility.

0 commit comments

Comments
 (0)