[Kotlin] google.api.field_behavior from proto file generates unresolved reference and results in compile error
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
Issue: Compile error on generated kotlin code
Proto file
I have a proto file with field_behavior attribute for a parameter.
import "buf/validate/validate.proto";
import "google/api/field_behavior.proto";
message GetABCRequest {
string item_id = 1 [
(buf.validate.field).string = {min_len: 1},
(google.api.field_behavior) = REQUIRED
];
}
Generated code:
import com.google.api.FieldBehavior
import com.google.api.FieldBehaviorOption
public class GetABCRequest(
@FieldBehaviorOption(value = [
FieldBehavior.REQUIRED
])
@field:WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#STRING",
label = WireField.Label.OMIT_IDENTITY,
jsonName = "itemId",
schemaIndex = 0,
)
public val item_id: String = "",
unknownFields: ByteString = ByteString.EMPTY,
) : Message<GetABCRequest, Nothing>(ADAPTER, unknownFields) {
"Config":
wire {
...
protoPath {
srcJar("com.google.api.grpc:proto-google-common-protos:2.45.1")
srcJar("build.buf:protovalidate:0.4.2")
}
...
}
dependencies {
...
implementation("com.google.api.grpc:proto-google-common-protos:2.45.1")
...
}
Issue:
Unresolved reference 'FieldBehaviorOption'.
import com.google.api.FieldBehaviorOption
There is no FieldBehaviorOption in google library to refer.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing generation from the provided proto file and Wire configuration, then inspect how google.api.field_behavior is mapped into generated Kotlin annotations. Compare the generated imports with the declarations available in proto-google-common-protos; done means the generated Kotlin compiles without the unresolved FieldBehaviorOption reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100