@@ -161,6 +161,29 @@ the user's behalf.
161161A 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.
181204Requiring the annotation also forces the API author to explicitly consider the
182205behavior 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
185208backwards-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
191216In 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
198224surpass 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