googleapis / googleapis/api-linter

`core::0132::request-parent-required` false positive when the request message in a separate file

Open
#1,588 4 comments 0 reactions 0 assignees View on GitHub
priority: p2 type: bug
Dominant language
Go
Stars
765
Forks
181
Avg merge
2d 12h
Merged PRs (30d)
3

Description

#### Environment details

- OS: Windows
- Package version: `api-linter 2.0.0`

#### Steps to reproduce

1. Make sure `core::0132::request-parent-required` is enabled.
2. Create a `List` method for a top-level resource. Per https://protobuf.dev/best-practices/1-1-1/ use a separate `.proto` for the request message.

```protobuf
// `api/v1/test.proto` file
syntax = "proto3";

package api.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";

import "api/v1/list_items_request.proto";

service ItemApi {
rpc ListItems(ListItemsRequest) returns (ListItemsResponse) {
option (google.api.http) = {
get : "/v1/items"
};
option (google.api.method_signature) = "";
}
}

message Item {
option (google.api.resource) = {
type: "whatever.googleapis.com/Item"
pattern: "items/{item}"
};

string name = 1 [(google.api.field_behavior) = IDENTIFIER];
}

message ListItemsResponse {
repeated Item items = 1;

string next_page_token = 2;
}
```

```protobuf
// `api/v1/list_items_request.proto` file
syntax = "proto3";

package api.v1;

import "google/api/field_behavior.proto";

message ListItemsRequest {
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];

string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
}
```

`api.v1.ListItemsRequest` is flagged with `core::0132::request-parent-required`, however, the `api.v1.Item` resource has no parent.

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.