AIP-4235

Automatically populate fields in the request message

For APIs that leverage request idempotency as described via AIP-155, APIs may choose to have the client libraries automatically populate fields such as request_id if they are not already set by the customer.

Note: This feature is primarily written for request_id fields within the request message. Nonetheless, this feature must work for a field of any name, as long as the conditions below hold true.

Guidance

APIs may configure fields in the request message for automatic population. For a field to be automatically populated, all the conditions below must be true:

Expected Generator and Client Library Behavior

If the aforementioned requirements are met for a given field, client library generators must enable automatic population of said field in the generated client.

The field must be automatically populated if and only if one of the following conditions holds:

  • The field supports explicit presence, and has not been set by the user
  • The field doesn't support explicit presence, and its value is the empty string (i.e. the default value)

If a field is specified in the auto_populated_fields, but does not meet the structural requirements, the client library generators must not enable automatic population for that field. Client library generators may emit an error during generation.

Client libraries must reuse automatically populated values for retries of the same request. In other words, the automatically populated fields must not be regenerated for each RPC attempt with the same request message.