Skip to content

Commit 6e52d72

Browse files
authored
fix(AIP-155): add format extension guidance (#1234)
1 parent 8e07336 commit 6e52d72

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

aip/general/0155.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ message CreateBookRequest {
4141
// A unique identifier for this request. Restricted to 36 ASCII characters.
4242
// A random UUID is recommended.
4343
// This request is only idempotent if a `request_id` is provided.
44-
string request_id = 3;
44+
string request_id = 3 [(google.api.field_info).format = UUID4];
4545
}
4646
```
4747

@@ -56,6 +56,9 @@ message CreateBookRequest {
5656
- Request IDs **should** be able to be UUIDs, and **may** allow UUIDs to be the
5757
only valid format. The format restrictions for request IDs **must** be
5858
documented.
59+
- Request IDs that are UUIDs **must** be annotated with the
60+
`google.api.FieldInfo.Format` value `UUID4` using the extension
61+
`(google.api.field_info).format = UUID4`. See [AIP-202](./0202.md) for more.
5962

6063
### Stale success responses
6164

@@ -75,7 +78,17 @@ response with a similar response that reflects more current data.
7578
- For how to retry errors in client libraries, see
7679
[AIP-4221](https://aip.dev/4221).
7780

81+
## Rationale
82+
83+
### Using UUIDs for request identification
84+
85+
When a value is required to be unique, leaving the format open-ended can lead to
86+
API consumers incorrectly providing a duplicate identifier. As such,
87+
standardizing on a universally unique identifier drastically reduces the chance
88+
for collisions when done correctly.
89+
7890
## Changelog
7991

92+
- **2023-10-02**: Add UUID format extension guidance.
8093
- **2019-08-01**: Changed the examples from "shelves" to "publishers", to
8194
present a better example of resource ownership.

0 commit comments

Comments
 (0)