Skip to content

Commit dfc45a0

Browse files
committed
@sanderegg review: doc rationale
1 parent 8156d87 commit dfc45a0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/models-library/src/models_library/batch_operations.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
"""
2+
3+
# Batch Operations Rationale:
4+
5+
Please preserve the following behaviors when implementing batch operations:
6+
7+
| Case | Behavior | Justification |
8+
| -------------- | ------------------------------------------ | --------------------------- |
9+
| Empty `names` | `400 Bad Request` | Invalid input |
10+
| Some missing | `200 OK`, with `missing` field | Partial success |
11+
| Duplicates | Silently deduplicate | Idempotent, client-friendly |
12+
| Response order | Preserve request order (excluding missing) | Deterministic, ergonomic |
13+
14+
15+
- `BatchGet` is semantically distinct from `List`.
16+
- `List` means “give me everything you have, maybe filtered.”
17+
- `BatchGet` means “give me these specific known resources.”
18+
- Passing an empty list means you’re not actually identifying anything to fetch — so it’s a client error (bad request), not a legitimate “empty result.”
19+
- This aligns with the principle: If the request parameters are syntactically valid but semantically meaningless, return 400 Bad Request.
20+
21+
# References:
22+
- https://google.aip.dev/130
23+
- https://google.aip.dev/231
24+
"""
25+
126
from typing import Annotated, Generic, TypeVar
227

328
from common_library.basic_types import DEFAULT_FACTORY

0 commit comments

Comments
 (0)