Cryptic TypeError in proto-plus during assignment with invalid type
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start in proto/message.py at setattr around the reported MergeFrom call, then trace the initialization and MergeFrom paths mentioned in the issue. Reproduce the sample assignment with batch.pyspark_batch.args = [1000] and verify that the resulting TypeError identifies the PysparkBatch message, the args field, and the invalid value.
Written by the indexing model from the issue text.
Description
Determine this is the right repository
- I determined this is the correct repository in which to report this bug.
Summary of the issue
Context:
When setting a field on a protobuf message using proto-plus with an invalid type or structure, the underlying protocol buffer library fails during initialization or merging.
Expected Behavior:
proto-plus should catch the TypeError and re-raise it with a more descriptive message that includes the specific message class and field name, aiding in debugging type mismatches.
Actual Behavior:
The library raises a cryptic TypeError: bad argument type for built-in operation without any context about which field or message class caused the failure.
API client name and version
proto-plus
Reproduction steps: code
from google.cloud import dataproc_v1
def sample_create_batch():
batch = dataproc_v1.Batch()
# Provide a type that is not a string in the args list. args expects a MutableSequence[str]
batch.pyspark_batch.args = [1000]
sample_create_batch()
Reproduction steps: supporting files
file: mydata.csv
alpha,1,3
beta,2,5
Reproduction steps: actual results
Traceback (most recent call last):
File "test.py", line 42, in
sample_create_batch()
File "test.py", line 24, in sample_create_batch
batch.pyspark_batch.args = [1000 ]
File "/env/lib/python3.11/site-packages/proto/message.py", line 944, in setattr
self._pb.MergeFrom(self._meta.pb(**{key: pb_value}))
TypeError: bad argument type for built-in operation
Reproduction steps: expected results
TypeError: Failed to set field 'args' on PysparkBatch with value [1000]. Underlying error: bad argument type for built-in operation.
OS & version + platform
Linux (Google Cloud Shell) / macOS
Python environment
Python 3.12
Python dependencies
No response
Additional context
The cryptic error is thrown directly from the underlying protocol buffers MergeFrom execution inside proto/message.py. Wrapping the initialization and MergeFrom calls in try-except blocks to provide contextual wrapper errors would greatly improve the developer experience.
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 1.8k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 173
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from googleapis/google-cloud-python
-
firestore: field path with a quoted name ending in a backslash is misparsedPossibly taken @sebxt claimed this 25 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
googleapis/google-cloud-python#18771 ·
Maintainers usually reply within 1 day
-
api: spanner type: feature request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
googleapis/google-cloud-python#18584 ·
Maintainers usually reply within 1 day
-
auth: `impersonated_credentials` loses `subject` on copy, so `with_scopes()` and `with_quota_project()` turn off domain wide delegationPossibly taken @Om-singhaI claimed this 55 days ago. Openauth priority: p2 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
googleapis/google-cloud-python#18428 ·
Maintainers usually reply within 1 day
-
A client called `run_in_transaction` be stuck if Spanner is downPossibly taken @founderinaction claimed this 7 days ago. Openpriority: p2 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/google-cloud-python#18375 · 1 comment ·
Maintainers usually reply within 1 day
-
ci: enable --strict flag in presubmit twine_checkMay be free again @ohmayr claimed this 44 days ago, and no pull request is open. Open
Difficulty 1/5 Under an hour Newbie friendliness 76/100
googleapis/google-cloud-python#18339 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in googleapis/google-cloud-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
cpp-best-practices/project_validator#267 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Project-N-E-K-O/N.E.K.O#3725 ·
Maintainers usually reply within 1 day
-
[Bug] Sending a Telegram message chain twice duplicates mentionsPossibly taken @123XieC claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AstrBotDevs/AstrBot#11125 ·
Maintainers usually reply within 1 day
-
backend bug priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nooriegarg/ContribIQ#73 ·
Maintainers usually reply within 1 day
-
bug p3 security
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day