I'm building an API to host on Google API Gateway.
A recent change was to integrate with protovalidate for simple request validation.
Upon doing so, I began getting the following error when pushing my proto descriptor to API Gateway:
Error: Error creating ApiConfig: googleapi: Error 400: Invalid file descriptor set "./../../api-config/build/descriptors/api_descriptor.pb": generic::invalid_argument: Invalid file descriptor set "./../../api-config/build/descriptors/api_descriptor.pb": proto: message field "buf.validate.FieldPathElement.field_type" cannot resolve type: "google.protobuf.FieldDescriptorProto.Type" not found
I'm using gradle to build the descriptor, but I get this error when I manually run protoc and explicitly include the google.protobuf.descriptor.proto as well. At this point I'm at a loss for how to fi this issue. It occurs as soon as I include protovalidate as part of the build, even if it's not used in my protos.
Here's my current gradle file, some lines commented out to reduce build scope in an attempt to identify the issue:
import com.google.protobuf.gradle.*
import java.nio.file.Paths
plugins {
id("kotlin")
id("com.google.protobuf")
}
repositories {
mavenCentral()
}
// ---- Versions ----
val protobufVersion = "4.31.1"
val grpcVersion = "1.71.0"
val grpcKotlinVersion = "1.4.3"
val protoValidateVersion = "0.12.0"
// api("io.grpc:grpc-kotlin-stub:$grpcKotlinVersion")
// api("com.google.protobuf:protobuf-kotlin:$protobufVersion")
api("com.google.protobuf:protobuf-java:$protobufVersion")
// implementation("io.grpc:grpc-protobuf:$grpcVersion")
protobuf("com.google.api.grpc:proto-google-common-protos:2.41.0") // has google/api/*.proto
// protobuf("com.google.protobuf:protoc:$protobufVersion")
protobuf("build.buf:protovalidate:$protoValidateVersion")
}
sourceSets {
named("main") {
proto {
srcDir("$projectDir/proto")
include("**.*.proto")
}
}
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:$protobufVersion" }
plugins {
// create("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" }
// create("grpckt") { artifact = "io.grpc:protoc-gen-grpc-kotlin:$grpcKotlinVersion:jdk8@jar" }
}
generateProtoTasks {
all().configureEach {
// Kotlin message classes
// builtins {
// create("kotlin")
// }
// JVM/Kotlin stubs
// plugins {
// create("grpc")
// create("grpckt")
// }
// Produce a descriptor set we can hand to Terraform
this as GenerateProtoTask
generateDescriptorSet = true
descriptorSetOptions.apply {
path = "$buildDir/descriptors/api_descriptor.pb"
includeImports = true
includeSourceInfo = true
}
}
}
}
I've attempted the following with the same results:
- Building the descriptor with protoc directly
- Explicitly including the google.protobuf library
- Explicitly including the google.protobuf.descriptor file as a source
Removing the protovalidate dependency fixes the issue, but of course that means I don't get protovalidate functionality.
protocequivalent command did you use? Are you ensuring thatdescriptor.protois included forFileDescriptorProto.Type?protovalidaterepo and am able to compile it withprotocwithout issue to a descriptor.