diff --git a/rules/aip0121/resource_must_support_list.go b/rules/aip0121/resource_must_support_list.go index 036816cc5..6e0f9620f 100644 --- a/rules/aip0121/resource_must_support_list.go +++ b/rules/aip0121/resource_must_support_list.go @@ -34,12 +34,12 @@ var resourceMustSupportList = &lint.ServiceRule{ // resources which have a List method, and which ones do not. for _, m := range s.GetMethods() { if utils.IsListMethod(m) { - if msg := utils.GetListResourceMessage(m); msg != nil { + if msg := utils.GetListResourceMessage(m); msg != nil && utils.IsResource(msg) { t := utils.GetResource(msg).GetType() resourcesWithList.Add(t) } } else if utils.IsCreateMethod(m) || utils.IsUpdateMethod(m) || utils.IsGetMethod(m) { - if msg := utils.GetResponseType(m); msg != nil { + if msg := utils.GetResponseType(m); msg != nil && utils.IsResource(msg) { // Skip tracking Singleton resources, they do not need List. if utils.IsSingletonResource(msg) { continue diff --git a/rules/aip0121/resource_must_support_list_test.go b/rules/aip0121/resource_must_support_list_test.go index 5f9f4354d..5f22c7e69 100644 --- a/rules/aip0121/resource_must_support_list_test.go +++ b/rules/aip0121/resource_must_support_list_test.go @@ -78,6 +78,9 @@ func TestResourceMustSupportList(t *testing.T) { {"ValidIgnoreSingleton", ` rpc GetBookCover(GetBookCoverRequest) returns (BookCover) {}; `, nil}, + {"ValidIgnoreNonResource", ` + rpc GetBookCover(GetBookCoverRequest) returns (Other) {}; + `, nil}, } { t.Run(test.name, func(t *testing.T) { file := testutils.ParseProto3Tmpl(t, ` @@ -139,6 +142,10 @@ func TestResourceMustSupportList(t *testing.T) { repeated Book books = 1; string next_page_token = 2; } + + message Other { + string other = 1; + } `, test) s := file.GetServices()[0] got := resourceMustSupportList.Lint(file)