Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically populate request_id-like fields to make requests idempotent #13595

Closed
coryan opened this issue Feb 12, 2024 · 0 comments · Fixed by #13615
Closed

Automatically populate request_id-like fields to make requests idempotent #13595

coryan opened this issue Feb 12, 2024 · 0 comments · Fixed by #13615
Assignees
Labels
cpp: generator Issues related to the C++ micro-generator type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@coryan
Copy link
Contributor

coryan commented Feb 12, 2024

Some services have fields that (when populated with unique values) make the requests idempotent. An example is service control with fields like this:

  // Optional. A unique identifier for this request. UUID is the recommended
  // format, but other formats are still accepted. This request is only
  // idempotent if a `request_id` is provided.
  string request_id = 5 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];

https://github.com/googleapis/googleapis/blob/7d73737e0e826ac683a4b5b19352feabf51bbc57/google/storage/control/v2/storage_control.proto#L202-L208

The field does not need to be called request_id. The name of the field comes from the service config YAML file, for example:

publishing:
  method_settings:
  - selector: google.storage.control.v2.StorageControl.CreateFolder
    auto_populated_fields:
    - request_id

https://github.com/googleapis/googleapis/blob/65b63cc4440e642d95a0c9562233f9ef2511c787/google/storage/control/v2/storage_v2.yaml#L44-L48

The full set of conditions is then:

  • The field must appear in the YAML file.
  • The field is a non-repeated string.
  • The field has the google.api.field_info annotation
  • The field format is UUID4

See Also

go/client-populate-request-id-prd
go/client-populate-request-id-design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp: generator Issues related to the C++ micro-generator type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant