Skip to content

Commit 19da70f

Browse files
authored
feat(AIP-203): document field behavior compatibility (#1172)
1 parent e05dba5 commit 19da70f

4 files changed

Lines changed: 44 additions & 8 deletions

File tree

aip/general/0134.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ does not exist, the service **must** error with `NOT_FOUND` (HTTP 404) unless
284284

285285
## Changelog
286286

287+
- **2023-07-17**: Make `update_mask` name guidance a **must**.
287288
- **2022-11-04**: Aggregated error guidance to AIP-193.
288289
- **2022-06-02**: Changed suffix descriptions to eliminate superfluous "-".
289290
- **2021-11-04**: Changed the permission check if `allow_missing` is set.

aip/general/0161.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,7 @@ service considers invalid).
146146
When writing data, field masks **should** return an `INVALID_ARGUMENT` error if
147147
an entry points to a value that can not exist; however, the service **may**
148148
permit deletions.
149+
150+
## Changelog
151+
152+
- **2023-07-17**: Move `update_mask` guidance to AIP-134.

aip/general/0180.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ version.
235235

236236
## Further reading
237237

238+
- For compatibility around field behavior, see [AIP-203][].
238239
- For compatibility around pagination, see [AIP-158][].
239240
- For compatibility around long-running operations, see [AIP-151][].
240241
- For understanding stability levels and expectations, see [AIP-181][].
@@ -243,6 +244,7 @@ version.
243244

244245
## Changelog
245246

247+
- **2023-07-26**: Added reference to field behavior compatibility.
246248
- **2023-07-26**: Added note on APIs which have limited clients.
247249
- **2022-08-11**: Added "Moving components between files" section.
248250
- **2022-06-01**: Added more links to other AIPs with compatibility concerns
@@ -254,6 +256,7 @@ version.
254256
[aip-151]: ./0151.md
255257
[aip-158]: ./0158.md
256258
[aip-181]: ./0181.md
259+
[aip-203]: ./0203.md
257260
[aip-4231]: ./client-libraries/4231.md
258261
[aip-4232]: ./client-libraries/4232.md
259262
[ec2]: https://aws.amazon.com/blogs/aws/theyre-here-longer-ec2-resource-ids-now-available/

aip/general/0203.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,29 @@ the user's behalf.
161161
A resource with an unordered list **may** return the list in a stable order, or
162162
**may** return the list in a randomized, unstable order.
163163

164+
## Backwards compatibility
165+
166+
Adding or changing `google.api.field_behavior` values can represent a semantic
167+
change in the API that is perceived as incompatible for existing clients. The
168+
following are examples of backwards incompatible changes with
169+
`google.api.field_behavior`:
170+
171+
* Adding `REQUIRED` to an existing field previously considered `OPTIONAL`
172+
(implicitly or otherwise).
173+
* Adding a new field annotated as `REQUIRED` to an existing request message.
174+
* Adding `OUTPUT_ONLY` to an existing field previously accepted as input
175+
* Removing `OUTPUT_ONLY` from an existing field previously ignored as input
176+
* Adding `INPUT_ONLY` to an existing field previously emitted as output
177+
* Adding `IMMUTABLE` to an existing field previously considered mutable
178+
179+
There are some changes that *are* backwards compatible, which are as follows:
180+
181+
* Adding `OPTIONAL` to an existing field
182+
* Changing from `REQUIRED` to `OPTIONAL` on an existing field
183+
* Removing `REQUIRED` from an existing field
184+
* Removing `INPUT_ONLY` from an existing field previously excluded in responses
185+
* Removing `IMMUTABLE` from an existing field previously considered immutable
186+
164187
## Rationale
165188

166189
### Required set of annotations
@@ -181,29 +204,34 @@ behavior improves programmatic clients and user understanding.
181204
Requiring the annotation also forces the API author to explicitly consider the
182205
behavior when initially authoring of the API.
183206

184-
Modifying field behavior after initial authoring results in
207+
Modifying field behavior after initial authoring can result in
185208
backwards-incompatible changes in clients. For example, making an optional field
186-
required, results in backwards-incompatible changes in the method signature of
187-
an RPC or a resource in an [IaC][] client.
209+
required results in backwards-incompatible changes in the method signature of an
210+
RPC or a resource in an [IaC][] client. See the
211+
[Backwards compatibility](#backwards-compatibility) section for more detailed
212+
compatibility guidance.
188213

189214
## History
190215

191216
In 2023-05 field_behavior was made mandatory. Prior to this change, the
192-
annotation was often omitted. Its values, e.g. REQUIRED, OUTPUT_ONLY, and
193-
IMMUTABLE, are relied upon to produce high quality clients. Further, when the
194-
value is added after the fact or changes, within a major version, it is
195-
backwards-incompatible, which is likely to break clients.
217+
annotation was often omitted. Its values are relied upon to produce high quality
218+
clients. Furthermore, adding or changing some of the field_behavior values after
219+
the fact within a major version can be backwards-incompatible. See the
220+
[Backwards compatibility](#backwards-compatibility) section for more detailed
221+
compatibility guidance.
196222

197-
The benefits of requiring field_behavior, at the time that the API is authored,
223+
The benefits of requiring field_behavior at the time that the API is authored
198224
surpass the costs to clients and API users of not doing so.
199225

200226
[aip-133]: ./0133.md
201227
[aip-134]: ./0134.md
228+
[aip-180]: ./0180.md
202229
[google.api.FieldBehavior]: https://github.com/googleapis/googleapis/blob/master/google/api/field_behavior.proto#L49
203230
[IaC]: ./0009.md#iac
204231

205232
## Changelog
206233

234+
- **2023-07-20**: Describe compatibility guidance with new section.
207235
- **2023-05-24**: Clarify that `IMMUTABLE` does not imply input nor required.
208236
- **2023-05-10**: Added guidance to require the annotation.
209237
- **2020-12-15**: Added guidance for `UNORDERED_LIST`.

0 commit comments

Comments
 (0)