feat(frontier): migrate from PGV to buf protovalidate#463
feat(frontier): migrate from PGV to buf protovalidate#463
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis pull request migrates protobuf validation annotations in multiple proto files from Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest Buf updates on your PR. Results from workflow Validate / validate (pull_request).
|
- Replace import "validate/validate.proto" with "buf/validate/validate.proto" - Convert (validate.rules) annotations to (buf.validate.field) - Convert PGV ignore_empty to protovalidate IGNORE_IF_ZERO_VALUE - Convert (validate.rules).message.required to (buf.validate.field).required - Remove envoyproxy/protoc-gen-validate dependency from buf.yaml
98ee661 to
2086944
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
raystack/frontier/v1beta1/frontier.proto (1)
1661-1664: Keep request-body name validators in sync with the model messages.
Organization.name,Project.name,Group.name, andMetaSchema.nameinraystack/frontier/v1beta1/models.protoall requiremin_len: 2, but the corresponding request bodies here only validate the pattern. As written, create/update calls can accept one-character names that fall outside the public model contract.♻️ Suggested change
message OrganizationRequestBody { string name = 1 [ + (buf.validate.field).string.min_len = 2, (buf.validate.field).string.pattern = "^[A-Za-z0-9-_]+$", (google.api.field_behavior) = REQUIRED ];message ProjectRequestBody { string name = 1 [ + (buf.validate.field).string.min_len = 2, (buf.validate.field).string.pattern = "^[A-Za-z0-9-_]+$", (google.api.field_behavior) = REQUIRED ];message GroupRequestBody { string name = 1 [ + (buf.validate.field).string.min_len = 2, (buf.validate.field).string.pattern = "^[A-Za-z0-9-_]+$", (google.api.field_behavior) = REQUIRED ];message MetaSchemaRequestBody { string name = 1 [ + (buf.validate.field).string.min_len = 2, (buf.validate.field).string.pattern = "^[A-Za-z0-9-_]+$", (google.api.field_behavior) = REQUIRED ];Also applies to: 1939-1942, 2202-2205, 2406-2409
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@raystack/frontier/v1beta1/frontier.proto` around lines 1661 - 1664, The request message string fields for names (e.g., the field `name` used in request messages that correspond to the model messages Organization.name, Project.name, Group.name, and MetaSchema.name) only enforce a pattern; update those field options to also include a minimum length validator of 2 to match the model contract (add `(buf.validate.field).string.min_len = 2` alongside the existing pattern and field_behavior options) so create/update request bodies cannot accept single-character names; apply the same change for the other analogous `name` request fields referenced in the diff (the similar blocks at the other locations).raystack/frontier/v1beta1/admin.proto (1)
937-939: Align the admin org-name rule withOrganization.name.
raystack/frontier/v1beta1/models.protorequiresOrganization.nameto havemin_len: 2, but this request body only checks the pattern. That drift lets admin create accept one-character names while the returned model type is stricter.♻️ Suggested change
string name = 1 [ + (buf.validate.field).string.min_len = 2, (buf.validate.field).string.pattern = "^[A-Za-z0-9-_]+$", (google.api.field_behavior) = REQUIRED ];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@raystack/frontier/v1beta1/admin.proto` around lines 937 - 939, The request field "name" (string name = 1) currently only enforces a pattern but must match the stricter Organization.name rules in models.proto; update the proto validation on this field to include the same minimum length constraint (e.g. add (buf.validate.field).string.min_len = 2) so the admin request cannot accept single-character names and remains consistent with Organization.name validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@raystack/frontier/v1beta1/admin.proto`:
- Around line 937-939: The request field "name" (string name = 1) currently only
enforces a pattern but must match the stricter Organization.name rules in
models.proto; update the proto validation on this field to include the same
minimum length constraint (e.g. add (buf.validate.field).string.min_len = 2) so
the admin request cannot accept single-character names and remains consistent
with Organization.name validation.
In `@raystack/frontier/v1beta1/frontier.proto`:
- Around line 1661-1664: The request message string fields for names (e.g., the
field `name` used in request messages that correspond to the model messages
Organization.name, Project.name, Group.name, and MetaSchema.name) only enforce a
pattern; update those field options to also include a minimum length validator
of 2 to match the model contract (add `(buf.validate.field).string.min_len = 2`
alongside the existing pattern and field_behavior options) so create/update
request bodies cannot accept single-character names; apply the same change for
the other analogous `name` request fields referenced in the diff (the similar
blocks at the other locations).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 42d38e6a-2200-4d2d-adf0-e748db0dd55b
⛔ Files ignored due to path filters (1)
buf.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
buf.yamlraystack/frontier/v1beta1/admin.protoraystack/frontier/v1beta1/frontier.protoraystack/frontier/v1beta1/models.proto
💤 Files with no reviewable changes (1)
- buf.yaml
| (buf.validate.field).string = {min_len: 1}, | ||
| (buf.validate.field).string.uuid = true |
There was a problem hiding this comment.
lets merge these into one?
| (buf.validate.field).string = {min_len: 1}, | |
| (buf.validate.field).string.uuid = true | |
| (buf.validate.field).string = {min_len: 1, uuid: true} |
Summary
envoyproxy/protoc-gen-validatetobuf/validate(protovalidate)(validate.rules)annotations to(buf.validate.field)ignore_empty: truewith protovalidateignore: IGNORE_IF_ZERO_VALUE(validate.rules).message.requiredto(buf.validate.field).requiredbuf.build/envoyproxy/protoc-gen-validatedependency frombuf.yamlTest plan
buf buildpassesbuf lintpasses