Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max limit for refs or values in requests #21

Merged
merged 3 commits into from
Nov 6, 2023
Merged

Conversation

mfridman
Copy link
Member

@mfridman mfridman commented Nov 6, 2023

This PR adds max_items to GetOwnersRequest.

I think we should avoid unbounded repeated refs and have sane limits. If a client needs to resolve >250 IDs or names, they can hit the endpoint multiple times.

Although it's not a list endpoint, used 250 for parity.

@mfridman mfridman requested a review from bufdev as a code owner November 6, 2023 19:14
@bufdev
Copy link
Member

bufdev commented Nov 6, 2023

If we do this, we should agree on a global max, i.e. all places that take repeated Refs should have the same limit. I'm fine with 250, but let's add this for the whole API.

@bufdev
Copy link
Member

bufdev commented Nov 6, 2023

Includes but may not be limited to:

buf/registry/owner/v1beta1/owner_service.proto:36:  repeated OwnerRef owner_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/owner/v1beta1/user_service.proto:51:  repeated UserRef user_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/owner/v1beta1/user_service.proto:151:  repeated UserRef user_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/branch_service.proto:44:  repeated BranchRef branch_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/branch_service.proto:54:  repeated ModuleRef module_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/tag_service.proto:48:  repeated TagRef tag_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/tag_service.proto:114:  repeated TagRef tag_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/module_service.proto:54:  repeated ModuleRef module_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/module_service.proto:163:  repeated ModuleRef module_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/vcs_commit_service.proto:39:  repeated VCSCommitRef vcs_commit_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/module/v1beta1/commit_service.proto:81:  repeated ResourceRef resource_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/owner/v1beta1/organization_service.proto:51:  repeated OrganizationRef organization_refs = 1 [(buf.validate.field).repeated.min_items = 1];
buf/registry/owner/v1beta1/organization_service.proto:139:  repeated OrganizationRef organization_refs = 1 [(buf.validate.field).repeated.min_items = 1];

@@ -264,7 +267,10 @@ message GetCommitNodesRequest {
bool allow_paths_not_exist = 3;
}
// The File sets to request.
repeated Value values = 1 [(buf.validate.field).repeated.min_items = 1];
repeated Value values = 1 [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a ref, but I presume we want to set an upper limit for these repeated values as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea

@mfridman mfridman changed the title Add max limit to the number of owner refs Add max limit for refs or values in requests Nov 6, 2023
@bufdev bufdev merged commit c184cfa into main Nov 6, 2023
6 checks passed
@bufdev bufdev deleted the mf-ownerservice branch November 6, 2023 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants