-
Notifications
You must be signed in to change notification settings - Fork 764
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
2 generated files with same message name makes deserialize response error #1462
Comments
Hi, thanks for the question :) May I ask if you're using Typescript or Common JS, and can you show me how you're importing the client classes? I'm wondering, if you could just use type aliases to get around this issue? e.g.
When you're importing the message classes like here?
|
i am using typescript. So you mean i need to edit the generated files manually? because the problem i am facing is that this is happening on the client generated files, not on my code, it is error when deserializing. I need a solution where i dont need to edit the generated code because i run the generation on every CI/CD to make sure it is updated if there are any proto changes |
Ohh i see.. no i wasn't suggesting you to edit the generated files manually.. I was thinking that if you have 2 different versions of Yeah it definitely doesn't make sense for you having to edit the generated files yourself :) So, if it's an error during deserializing, i guess the generated code has confused the 2 If you can provide some more details on what the generated files look like it might help with understanding of this issue. |
yes it confused the 2 statusresponse classes, when i call the request in the first client it checks the statusresponse class of the second class instead These are the classes generated, i omitted some item because i cannot disclose some of the item, but basically there are some differences:
and the other one is
the main function
|
@rizdaputra Aha i see! Thanks for providing the file content! I'm if you could could also share how "RequestStatusResponse" was imported in the 2 generated services? What's the namespace that was used? And would you be able to specify different namespaces so they can be imported in different ways (to avoid the confusions)? |
i think in the auto generated files it is always generated imports like this
so when calling it is doing You mean i change in the proto so the name will be different? I am searching for a solution because the owner of the proto is not me and it is used in multiple application, changing it would break multiple applications that are not maintained by me. Wondering if there is a way to add prefix or suffix when generating the service/client or is there another solution for this |
Could you share the exact command you used for generating the proto & grpc files? I'll take a look at if that's possible! Thanks! |
i used
|
@rizdaputra Hihi! Thanks for providing the commands you used! And sorry for the delay!! So I've tried creating 2 folders like below (under the echo folder):
With And when i run:
I'm getting 2 files, and one of them would be using That seems like it might work without conflict to me? Is this what you're seeing and would this potentially work for you? Thanks! |
@sampajano thank you for getting back and trying to replicate for me, in my case they are in a different folder. But yes code wise the generated code is correct, but when the code is compiled somehow the function calling is actually conflicting and the only one conflicting is the deserialize process of the response. i have another call that are exactly same and it is not conflicting. But when the same response type name with different structure, the type that is used for deserializing the response is wrong |
So i have different proto files, they have each a request that have same message response name but the value and structure are actually different. This cause problem whenever i declare both then one of them is rendered as that message even though i am calling the other function.
e.g.
ClientA has getStatus with response StatusResponse
ClientB has getStatus with response StatusResponse
but the StatusResponse definition in ClientA and ClientB is different but whenver i call each getStatus both are using the StatusResponse when doing assertion.
The text was updated successfully, but these errors were encountered: