Skip to content

feat: add protovalidate support to template#28

Merged
ankurs merged 2 commits intomainfrom
feat/protovalidate
Apr 6, 2026
Merged

feat: add protovalidate support to template#28
ankurs merged 2 commits intomainfrom
feat/protovalidate

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Apr 6, 2026

Summary

  • Add buf.build/bufbuild/protovalidate to buf.yaml deps
  • Import buf/validate/validate.proto in the proto template
  • Add example min_len = 1 validation annotation on EchoRequest.msg
  • Validation is enforced automatically by the protovalidate interceptor in the default ColdBrew interceptor chain (interceptors#35)

Depends on: go-coldbrew/interceptors#35

Test plan

  • Proto template compiles with buf validation annotations
  • EchoRequest with empty msg returns InvalidArgument

Summary by CodeRabbit

  • Chores
    • Enhanced API validation framework to enforce non-empty message field requirements, ensuring better data integrity and preventing invalid requests from being processed.

- Add buf.build/bufbuild/protovalidate to buf.yaml deps
- Import buf/validate/validate.proto in the proto template
- Add example min_len=1 validation on EchoRequest.msg
- Validation is enforced automatically by the protovalidate
  interceptor in the default ColdBrew chain
Copilot AI review requested due to automatic review settings April 6, 2026 02:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

Warning

Rate limit exceeded

@ankurs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 14 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 22 minutes and 14 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 19bffebf-221a-46a8-b507-a75598a4cb20

📥 Commits

Reviewing files that changed from the base of the PR and between d8cc82b and fd8d9dc.

⛔ Files ignored due to path filters (1)
  • {{cookiecutter.app_name}}/buf.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • {{cookiecutter.app_name}}/buf.yaml
📝 Walkthrough

Walkthrough

A Protobuf project is enhanced with validation capabilities by adding the protovalidate dependency to buf.yaml and importing validation rules into the proto definitions. The EchoRequest.msg field is constrained with a minimum length requirement of 1 character.

Changes

Cohort / File(s) Summary
Build Configuration
{{cookiecutter.app_name}}/buf.yaml
Added buf.build/bufbuild/protovalidate dependency to enable validation rule support.
Protocol Definitions
`{{cookiecutter.app_name}}/proto/{{cookiecutter.app_name
lower}}.proto`

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A validation charm we bring,
To make those proto messages sing!
No empty strings shall pass our gate,
With protovalidate, all feels great!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add protovalidate support to template' accurately describes the main change: adding protovalidate support to the template by adding the dependency to buf.yaml and validation annotations to the proto file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/protovalidate

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds protovalidate-based field validation to the generated service template so proto annotations compile and the default interceptor chain can enforce request validation.

Changes:

  • Add buf.build/bufbuild/protovalidate as a Buf module dependency.
  • Import buf/validate/validate.proto and add a min_len = 1 constraint to EchoRequest.msg in the template proto.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
{{cookiecutter.app_name}}/buf.yaml Adds the protovalidate BSR module dependency so buf/validate/validate.proto can be resolved.
`{{cookiecutter.app_name}}/proto/{{cookiecutter.app_name lower}}.proto`

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread {{cookiecutter.app_name}}/buf.yaml
- Add buf.build/bufbuild/protovalidate to buf.lock
- Remove unused buf.build/envoyproxy/protoc-gen-validate (old PGV)
- Update all buf deps to latest commits (googleapis, grpc-gateway, grpc)
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @{{cookiecutter.app_name}}/buf.yaml:
- Line 25: The buf.yaml currently includes an unused dependency
"buf.build/envoyproxy/protoc-gen-validate"; remove that entry from the deps list
so only "buf.build/bufbuild/protovalidate" (used by import
"buf/validate/validate.proto" and [(buf.validate.field).string.min_len = 1])
remains, ensuring buf.yaml's deps no longer contain
"buf.build/envoyproxy/protoc-gen-validate".

In @{{cookiecutter.app_name}}/proto/{{cookiecutter.app_name|lower}}.proto:
- Line 7: The gRPC server in InitGRPC (main.go) is missing the protovalidate
interceptor so the proto `min_len` rules won't be enforced; instantiate the
protovalidate validator (from the protovalidate package you imported) and
register its unary interceptor in the grpc.NewServer options passed by InitGRPC
(e.g., include protovalidate's UnaryServerInterceptor in the
grpc.UnaryInterceptor chain), then remove or correct the misleading proto
comment if you decide not to enable validation at runtime; reference the
InitGRPC function and the protovalidate interceptor symbol when making the
change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0c9c3f7a-0072-4ceb-8436-6a463604ee5b

📥 Commits

Reviewing files that changed from the base of the PR and between 31746df and d8cc82b.

📒 Files selected for processing (2)
  • {{cookiecutter.app_name}}/buf.yaml
  • {{cookiecutter.app_name}}/proto/{{cookiecutter.app_name|lower}}.proto

Comment thread {{cookiecutter.app_name}}/buf.yaml
@ankurs ankurs merged commit 71428a6 into main Apr 6, 2026
8 checks passed
@ankurs ankurs deleted the feat/protovalidate branch April 6, 2026 05:22
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