Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on annotations.proto #2927

Open
santhanamk opened this issue May 6, 2024 · 8 comments
Open

Crash on annotations.proto #2927

santhanamk opened this issue May 6, 2024 · 8 comments
Assignees
Labels

Comments

@santhanamk
Copy link

santhanamk commented May 6, 2024

I have this annotations.proto file:

// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

import "google/http.proto";
import "google/protobuf/descriptor.proto";
// ...

extend .google.protobuf.MethodOptions {
    HttpRule http = 72295728;
}

But when it gets processed by the Wire Gradle plugin (via Android Studio) I get this crash:

Cause: extensions are not allowed in proto3
for extend google.protobuf.MethodOptions (...app/src/main/proto/google/annotations.proto:28:1)

Is there a workaround or solution for this?

@oldergod
Copy link
Member

oldergod commented May 7, 2024

As the error specifies, you cannot define extensions in proto3 files. Change the syntax or don't use an extension?

@santhanamk
Copy link
Author

santhanamk commented May 7, 2024

Ok thanks for your reply! Why is it that other libraries like KrotoDC or even the protoc-gen/protobuf libraries for Java/Kotlin are able to process this file without crashing?

Is the Wire Compiler more strict?

Also, what would be an alternate syntax that I could use?

@oldergod
Copy link
Member

oldergod commented May 7, 2024

Thank you. It looks like we missed that when adding proto3 support. Extensions are allowed for defining options, even in proto3 files. I can fix that at some point but your best move right now would be to move this extension definition in a proto2 file.

@oldergod oldergod added the bug label May 7, 2024
@oldergod oldergod self-assigned this May 7, 2024
@oldergod
Copy link
Member

oldergod commented May 7, 2024

Actually @santhanamk you can get your build pass by removing the leading ..

- extend .google.protobuf.MethodOptions {
+ extend google.protobuf.MethodOptions {

@santhanamk
Copy link
Author

santhanamk commented May 7, 2024

@oldergod if I remove the .. I see this error:

Screenshot 2024-05-07 at 10 31 44 AM

I think it is due to the descriptor.proto import above.

For proto3 however, after I remove the . and do a Build in Android Studio wire is successful, and still generates all of the proto files. Do you think the HttpRule is getting ignored somehow?

If I downgrade to proto2 and move that extend into there then that does work as well.

Do you know by roughly when you could fix this bug? Thanks for your help.

@oldergod
Copy link
Member

oldergod commented May 7, 2024

Any syntax error in the .proto file is only noise. You gotta run Wire to be sure that it works or not.

@oldergod
Copy link
Member

oldergod commented May 7, 2024

The fix, I would not count on it before the summer. Might happen before.

@santhanamk
Copy link
Author

ok thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants