github.com/googleapis/api-linter@v1.65.2/docs/rules/0154/no-duplicate-etag.md (about) 1 --- 2 rule: 3 aip: 154 4 name: [core, '0154', no-duplicate-etag] 5 summary: | 6 Etag fields should not be set on request messages that include 7 the resource. 8 permalink: /154/no-duplicate-etag 9 redirect_from: 10 - /0154/no-duplicate-etag 11 --- 12 13 # Required etags 14 15 This rule enforces that `etag` fields are set on resources and requests that 16 reference those resources by name, but not on requests that include the 17 resource directly, as mandated in [AIP-154][]. 18 19 ## Details 20 21 This rule looks at any field named `etag` and complains if it is part of a 22 request message including a resource that itself includes an etag. 23 24 ## Examples 25 26 **Incorrect** code for this rule: 27 28 ```proto 29 // Incorrect. 30 message UpdateBookRequest { 31 Book book = 1; 32 google.protobuf.FieldMask update_mask = 2; 33 string etag = 3; // The Book message already includes etag. 34 } 35 ``` 36 37 **Correct** code for this rule: 38 39 ```proto 40 // Correct. 41 message UpdateBookRequest { 42 Book book = 1; 43 google.protobuf.FieldMask update_mask = 2; 44 } 45 ``` 46 47 ## Disabling 48 49 If you need to violate this rule, use a leading comment above the field. 50 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 51 52 ```proto 53 message UpdateBookRequest { 54 Book book = 1; 55 google.protobuf.FieldMask update_mask = 2; 56 // (-- api-linter: core::0154::no-duplicate-etag=disabled 57 // aip.dev/not-precedent: We need to do this because reasons. --) 58 string etag = 3; 59 } 60 ``` 61 62 If you need to violate this rule for an entire file, place the comment at the 63 top of the file. 64 65 [aip-154]: https://aip.dev/154 66 [aip.dev/not-precedent]: https://aip.dev/not-precedent