googleapis / googleapis/api-linter
Invalid AIP linter for AIP-123 generates false positive findings.
- Dominant language
- Go
- Stars
- 765
- Forks
- 181
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 3
Description
Thanks for stopping by to let us know something could be better!
**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.
Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the [Support page](https://cloud.google.com/support) to reach the most relevant engineers.
If the support paths suggested above still do not result in a resolution, please provide the following details.
#### Environment details
- Programming language: protocol buffers
- OS: Any
- Language runtime version: Any
- Package version: Any
#### Steps to reproduce
1. Create a protocol buffer message with a string field called `name`.
2. Run AIP linter against it.
3. The linter will complain with the message "Resource messages should include a `google.api.resource` annotation. https://linter.aip.dev/123/resource-annotation"
#### Description of the issue
1. [AIP-123](https://google.aip.dev/123) says "APIs **should** annotate the resource types for each resource in the API using the `google.api.resource` annotation". It does not specify how the resource type can be identified automatically.
2. [AIP-122](https://google.aip.dev/122) says "Resources **must** expose a `name` field that contains its resource name."
3. [AIP-123 Linter](https://linter.aip.dev/123/resource-annotation#details) "(...) assumes that messages with a `string name` field are resources unless the message name ends with `Request`."
AIP-123 linter recognizes messages with `name` field as resources, which is prune to false positives (see AIP-123), e.g. one may have messages with `string name` field, which are not resources. Then the linter requires them to have `google.api.resource` annotation, which is a **should** requirement only.
Proposed changes:
- AIP-123 linter checks performs different checks, which are defined in the AIP-122:
- "Patterns **must** correspond to the `resource name`",
- "Pattern variables (the segments within braces) **must** use `snake_case`, and **must not** use an `_id` suffix."
- AIP-122 linter checks that all messages with a `google.api.resource` annotation, which are assumed to be resources, have a `string name` field. This is also a heuristic, but should generate fewer false-positive, as it requires presence of the annotation to assume the message is a resource.
Contributor guide
Assessment
This issue has not been assessed yet.