feat(stencil): migrate proto to connectRPC with buf.validate#481
feat(stencil): migrate proto to connectRPC with buf.validate#481
Conversation
Remove gRPC-gateway HTTP annotations and OpenAPI options from StencilService proto in preparation for connectRPC migration. Replace google.api.field_behavior with buf.validate constraints for automatic request validation. Add Java options for multi-language support.
|
The latest Buf updates on your PR. Results from workflow Validate / validate (pull_request).
|
|
Warning Rate limit exceeded
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 56 minutes and 31 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe protobuf file updates validation annotations by replacing Google API field-behavior directives with Buf validation constraints. HTTP routing definitions for RPC methods are removed. String identifier fields now require minimum length constraints, numeric version fields require positive values, and enum fields restrict values to exclude unspecified/zero states. These changes maintain the same RPC signatures and message structures while modifying how field validation is specified. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@raystack/stencil/v1beta1/stencil.proto`:
- Around line 124-129: Add validation to reject unspecified enum values and zero
version IDs: for CreateSchemaRequest.format and
CreateSchemaRequest.compatibility, add a buf.validate rule to exclude the
*_UNSPECIFIED enum (e.g., (buf.validate.field).enum.not_in =
[Schema.Format.FORMAT_UNSPECIFIED] and similarly for Schema.Compatibility);
apply the same enum.not_in rule to CheckCompatibilityRequest.compatibility and
UpdateSchemaMetadataRequest.compatibility; for SearchRequest.version_id (the
oneof branch that selects version_id) add a numeric gt rule to require > 0
(e.g., (buf.validate.field).uint64.gt = 0) so selecting the version_id branch
cannot be zero.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d9204ef4-db1f-4bdc-b349-f6698d33e75d
📒 Files selected for processing (1)
raystack/stencil/v1beta1/stencil.proto
| message CreateSchemaRequest { | ||
| string namespace_id = 1; | ||
| string schema_id = 2; | ||
| bytes data = 3 [(google.api.field_behavior) = REQUIRED]; | ||
| string namespace_id = 1 [(buf.validate.field).string.min_len = 1]; | ||
| string schema_id = 2 [(buf.validate.field).string.min_len = 1]; | ||
| bytes data = 3 [(buf.validate.field).bytes.min_len = 1]; | ||
| Schema.Format format = 4; | ||
| Schema.Compatibility compatibility = 5; |
There was a problem hiding this comment.
Complete validation coverage for the remaining enum and version fields.
CreateSchemaRequest.format, CreateSchemaRequest.compatibility, CheckCompatibilityRequest.compatibility, and UpdateSchemaMetadataRequest.compatibility still accept *_UNSPECIFIED; SearchRequest.version_id still accepts 0 when that oneof branch is selected. This leaves gaps in the validation contract added elsewhere in this proto.
🛡️ Proposed validation additions
message CreateSchemaRequest {
string namespace_id = 1 [(buf.validate.field).string.min_len = 1];
string schema_id = 2 [(buf.validate.field).string.min_len = 1];
bytes data = 3 [(buf.validate.field).bytes.min_len = 1];
- Schema.Format format = 4;
- Schema.Compatibility compatibility = 5;
+ Schema.Format format = 4 [(buf.validate.field).enum = {defined_only: true, not_in: [0]}];
+ Schema.Compatibility compatibility = 5 [(buf.validate.field).enum = {defined_only: true, not_in: [0]}];
}
message CheckCompatibilityRequest {
string namespace_id = 1 [(buf.validate.field).string.min_len = 1];
string schema_id = 2 [(buf.validate.field).string.min_len = 1];
bytes data = 3 [(buf.validate.field).bytes.min_len = 1];
- Schema.Compatibility compatibility = 4;
+ Schema.Compatibility compatibility = 4 [(buf.validate.field).enum = {defined_only: true, not_in: [0]}];
}
message UpdateSchemaMetadataRequest {
string namespace_id = 1 [(buf.validate.field).string.min_len = 1];
string schema_id = 2 [(buf.validate.field).string.min_len = 1];
- Schema.Compatibility compatibility = 3;
+ Schema.Compatibility compatibility = 3 [(buf.validate.field).enum = {defined_only: true, not_in: [0]}];
}
message SearchRequest {
string namespace_id = 1;
string schema_id = 2;
string query = 3 [(buf.validate.field).string.min_len = 1];
oneof version {
bool history = 4;
- int32 version_id = 5;
+ int32 version_id = 5 [(buf.validate.field).int32 = {gt: 0}];
}
}Also applies to: 138-143, 161-165, 211-219
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@raystack/stencil/v1beta1/stencil.proto` around lines 124 - 129, Add
validation to reject unspecified enum values and zero version IDs: for
CreateSchemaRequest.format and CreateSchemaRequest.compatibility, add a
buf.validate rule to exclude the *_UNSPECIFIED enum (e.g.,
(buf.validate.field).enum.not_in = [Schema.Format.FORMAT_UNSPECIFIED] and
similarly for Schema.Compatibility); apply the same enum.not_in rule to
CheckCompatibilityRequest.compatibility and
UpdateSchemaMetadataRequest.compatibility; for SearchRequest.version_id (the
oneof branch that selects version_id) add a numeric gt rule to require > 0
(e.g., (buf.validate.field).uint64.gt = 0) so selecting the version_id branch
cannot be zero.
Summary
google.api.http) and OpenAPI (openapiv2) options from all StencilService RPCsgoogle.api.field_behaviorwithbuf.validateconstraints for automatic request validation viaconnectrpc.com/validatejava_multiple_files,java_package,java_outer_classname) for multi-language supportValidation rules added
string.min_len = 1on all ID/name fields (namespace_id, schema_id, query)bytes.min_len = 1on schema data fieldsint32.gt = 0on version_id fieldsenum.defined_only + not_in: [0]on format and compatibility enums (rejects UNSPECIFIED)Context
Part of the connectRPC migration for Stencil, following the same pattern established by Compass. The companion Stencil codebase PR will consume these updated protos.
Test plan
buf lintpassesbuf generateproduces valid Go + connectRPC code