@@ -59,6 +59,22 @@ rpc CreateBook(CreateBookRequest) returns (google.longrunning.Operation) {
5959- APIs with messages that return ` Operation ` ** must** implement the
6060 [ ` Operations ` ] [ lro ] service. Individual APIs ** must not** define their own
6161 interfaces for long-running operations to avoid non-uniformity.
62+ - If an RPC supports a [ validate-only mode] ( aip-163 ) , the response to a
63+ validation request ** must** be one of the following:
64+ - A successful response with an ` Operation ` which is already complete, with
65+ the ` done ` field set to ` true ` , and a valid (but potentially empty) response
66+ message in the ` response ` field, wrapped in a ` google.protobuf.Any ` message.
67+ The ` name ` field ** may** be empty, to avoid the service having to maintain
68+ state for successful validation.
69+ - An immediate error response (typically "bad request")
70+ - An ` Operation ` with the ` done ` field set to ` false ` , to indicate
71+ long-running validation. In this case, the ` name ` field ** must** be set,
72+ to allow clients to poll the long-running validation operation until it
73+ has completed. Successful validation ** must** eventually be represented by
74+ an operation with ` done=true ` and a valid (but potentially empty) wrapped
75+ response message in the ` response ` field. Unsuccessful validation ** must**
76+ eventually be represented by an operation with ` done=true ` and the error
77+ details provided in the ` error ` field.
6278
6379** Note:** User expectations can vary on what is considered "a significant
6480amount of time" depending on what work is being done. A good rule of thumb is
@@ -113,13 +129,30 @@ metadata message. The errors themselves **must** still be represented with a
113129Changing either the ` response_type ` or ` metadata_type ` of a long-running operation
114130is a breaking change.
115131
132+ ## Rationale
133+
134+ ### Validate-only behavior
135+
136+ The guidance for validate-only responses comes from a tension
137+ between clients, which benefit from "fully formed" operations that can
138+ be treated uniformly, and servers, which don't wish to maintain
139+ additional state for trivial operations. It seems counterintuitive
140+ that just validating a request should generate more state, but a
141+ full operation response that can be fetched later would either
142+ require that or "special" singleton operation IDs. The guidance
143+ provided is a compromise: by returning a "done" operation, clients
144+ can use existing logic to check that the operation has completed
145+ successfully (and therefore doesn't need to be fetched for an
146+ updated status) but server don't need to maintain any additional state.
147+
116148<!-- prettier-ignore-start -->
117149[ aip-128 ] : ./0128.md
118150[ aip-131 ] : ./0131.md
119151[ aip-132 ] : ./0132.md
120152[ aip-133 ] : ./0133.md
121153[ aip-134 ] : ./0134.md
122154[ aip-135 ] : ./0135.md
155+ [ aip-163 ] : ./0163.md
123156[ aip-193 ] : ./0193.md
124157[ aip-216 ] : ./0216.md
125158[ google.rpc.Status ] : https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto
@@ -130,7 +163,9 @@ is a breaking change.
130163
131164## Changelog
132165
133- - ** 2022-06-??** : Added compatibility section
166+ - ** 2024-04-23** : Provided pattern for validation on RPCs returning
167+ long-running operations.
168+ - ** 2022-05-31** : Added compatibility section.
134169- ** 2020-08-24** : Clarified that responses are not streaming responses.
135170- ** 2020-06-24** : Added guidance for parallel operations.
136171- ** 2020-03-20** : Clarified that both ` response_type ` and ` metadata_type ` are
0 commit comments