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

[Python] MergeFrom() raises TypeError for the same class #10040

Closed
parthea opened this issue May 25, 2022 · 7 comments
Closed

[Python] MergeFrom() raises TypeError for the same class #10040

parthea opened this issue May 25, 2022 · 7 comments
Assignees
Labels

Comments

@parthea
Copy link

parthea commented May 25, 2022

What version of protobuf and what language are you using?
Version: main
Language: Python

What operating system (Linux, Windows, ...) and version?
Linux

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.9.12

What did you do?
Steps to reproduce the behavior:

  1. Install the google-cloud-gke-hub client
  2. Run the sample code provided in Unable to configure config management with Clusters registered with Anthos googleapis/python-gke-hub#151

What did you expect to see
I expected the code to run without error.

What did you see instead?
I saw the following exception TypeError('Parameter to MergeFrom() must be instance of same class: expected MembershipSpec got google.cloud.gkehub_v1.configmanagement_v1.types.configmanagement.MembershipSpec.')

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

I'm working on troubleshooting an issue that a user reported in the python client library here where protobuf is raising Parameter to MergeFrom() must be instance of same class: . I'm able to re-create the error using the sample code that the user shared in the issue. I'm having trouble figuring out why these 2 classes are not the same. There is only one class with MembershipSpec and I'm not sure what's causing this issue. I tried debugging but I haven't been able to locate the discrepancy.
https://github.com/googleapis/python-gke-hub/search?q=%22class+MembershipSpec%22.

>>_FullyQualifiedClassName(msg.__class__)
'google.cloud.gkehub_v1.configmanagement_v1.types.configmanagement.MembershipSpec'
>>_FullyQualifiedClassName(cls)
'MembershipSpec'

image

@elharo elharo added the python label May 25, 2022
@zhangskz
Copy link
Member

What protobuf version are you on?

@parthea
Copy link
Author

parthea commented May 27, 2022

With protobuf==3.20.1 , I get TypeError('Parameter to MergeFrom() must be instance of same class: expected MembershipSpec got google.cloud.gkehub_v1.configmanagement_v1.types.configmanagement.MembershipSpec.')

With protobuf 4.21.0 I see a different error

  File "/usr/local/google/home/partheniou/git/python-gke-hub/check.py", line 62, in <module>
    create_feature(client, parent, membership_name)
  File "/usr/local/google/home/partheniou/git/python-gke-hub/check.py", line 27, in create_feature
    member_spec = MembershipFeatureSpec(
  File "/usr/local/google/home/partheniou/.pyenv/versions/py39/lib/python3.9/site-packages/proto/message.py", line 585, in __init__
    super().__setattr__("_pb", self._meta.pb(**params))
TypeError: Message must be initialized with a dict: google.cloud.gkehub.v1.MembershipFeatureSpec

@UrielShimony
Copy link

UrielShimony commented Jun 7, 2022

is there any news with this issue ?
(reproduced in our product as well only on Apple M1 )

@lhuhn-wish
Copy link

We are also seeing this error on Apple M1. It occurs at least as far back as protobuf==3.8.0 on Python 2.x.

@lhuhn-wish
Copy link

We were able to resolve this by following the ideas in #7408 and changing the path we import with.

@chikubee
Copy link

chikubee commented Jul 11, 2022

We were able to resolve this by following the ideas in #7408 and changing the path we import with.

@lhuhn-wish I am getting the same issue for different proto files. I tried the suggested changes but that does not seem to work with protobuf 3.20.1. Which protobuf version are you using?

@parthea
Copy link
Author

parthea commented Mar 7, 2023

I'm going to close this issue as my issue was unrelated to protobuf. I was using proto-plus which appears to have a bug in marshal.py. I've opened googleapis/proto-plus-python#348 to start the process of proposing a fix.

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

7 participants