Cryptic TypeError in proto-plus during assignment with invalid type
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- backend-api-design
Direzione di ricerca
Inizia in proto/message.py, in setattr, intorno alla chiamata MergeFrom segnalata, quindi segui i percorsi di inizializzazione e MergeFrom menzionati nell’issue. Riproduci l’assegnazione di esempio con batch.pyspark_batch.args = [1000] e verifica che il TypeError risultante identifichi il messaggio PysparkBatch, il campo args e il valore non valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 5.4k
- Fork
- 1.8k
- Merge medio
- 2g 7h
- PR unite (30g)
- 173
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/google-cloud-python
-
firestore: field path with a quoted name ending in a backslash is misparsedForse già presa @sebxt l’ha presa 25 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
googleapis/google-cloud-python#18771 ·
I maintainer di solito rispondono entro 1 giorno
-
api: spanner type: feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
googleapis/google-cloud-python#18584 ·
I maintainer di solito rispondono entro 1 giorno
-
auth: `impersonated_credentials` loses `subject` on copy, so `with_scopes()` and `with_quota_project()` turn off domain wide delegationForse già presa @Om-singhaI l’ha presa 55 giorni fa. Apertaauth priority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
googleapis/google-cloud-python#18428 ·
I maintainer di solito rispondono entro 1 giorno
-
A client called `run_in_transaction` be stuck if Spanner is downForse già presa @founderinaction l’ha presa 7 giorni fa. Apertapriority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
googleapis/google-cloud-python#18375 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
ci: enable --strict flag in presubmit twine_checkForse di nuovo libera @ohmayr l’ha presa 44 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
googleapis/google-cloud-python#18339 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleapis/google-cloud-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
cpp-best-practices/project_validator#267 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Project-N-E-K-O/N.E.K.O#3725 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Sending a Telegram message chain twice duplicates mentionsForse già presa @123XieC l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AstrBotDevs/AstrBot#11125 ·
I maintainer di solito rispondono entro 1 giorno
-
backend bug priority: high
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nooriegarg/ContribIQ#73 ·
I maintainer di solito rispondono entro 1 giorno
-
bug p3 security
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno