googleapis / googleapis/api-linter

aip0124: why do referenced resources need to be in the same package?

Open
#597 8 comments 2 reactions 0 assignees View on GitHub
type: feature request
Dominant language
Go
Stars
765
Forks
181
Avg merge
2d 12h
Merged PRs (30d)
3

Description

The implemented rule for AIP124 [enforces](https://github.com/googleapis/api-linter/blob/master/rules/aip0124/valid_reference.go#L91) that if a resource is referenced using `google.api.resource_reference` annotation, the referenced resource must be in the same package as the one referencing it. Otherwise, the linter will lint it as **"resource not found"**.

Why is this implemented this way ?? This requirement is not mentioned in [AIP124](https://google.aip.dev/124).

I think an explanation for this should be given in AIP124 or the requirement to be in the same package removed from the implementation of the rule.

Just to make it a bit clearer, here's an example. If we have 2 proto files, `dep.proto`, and `leaf.proto` (taken from the testing inside rule 124) like:

"dep.proto"
```
import "google/api/resource.proto";
package AAA
message Book {option (google.api.resource) = {
type: "library.googleapis.com/Book"
}
```
"leaf.proto": `
```
import "google/api/resource.proto";
import "dep.proto";
package BBB
message Foo {
string book = 1 [(google.api.resource_reference).{{.Field}} = "{{.Ref}}"];
}
```

AAA must be equal to BBB otherwise, the resource will be lint as not found.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.