googleapis / googleapis/google-cloud-python

Python renamed fields (e.g. "type_") break text_format.Parse

Offen
#16,207 3 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @ohmayr Auf GitHub ansehen
priority: p3 type: feature request
Vorherrschende Sprache
Python
Sterne
5.4k
Forks
1.8k
Ø Merge
3 T. 4 Std.
Gemergte PRs (30 T.)
122

Beschreibung

#### Environment details

- OS type and version: Linux 6.16.12-1rodete2-amd64
- Python version: `python --version`: Python 3.13.7
- pip version: `pip --version`: pip 25.3
- `gapic-generator` version: `pip show gapic-generator`: Version: 1.30.0

#### Steps to reproduce

1. Import a cloud sdk that has fields in the list of [reserved names](https://github.com/googleapis/gapic-generator-python/blob/b64e7a3351804613aaf56d7a699390d8dbc70712/gapic/utils/reserved_names.py)
2. Try to load textproto using `text_format.Parse`

Since the same textproto output loads fine in other languages (verified with go, for example), this seems like a bug in the python version of the generator, specifically that the proto descriptor returned by `.pb()` does not have the same field names as the actual proto.

There should be some way for users to parse textproto files that correspond to the released protos using the python sdk.

#### Code example

```python
from google.protobuf import text_format
from google.cloud import dlp_v2

# inlined for easy repro, actual contents would come from the Google-provided GCS object
text_proto_content = """
findings {
quote: "Test"
location {
container {
type: "Google Cloud Storage"
}
}
}
"""

output_message = dlp_v2.SaveToGcsFindingsOutput.pb()()
text_format.Parse(text_proto_content, output_message)
```

#### Stack trace
```
google.protobuf.text_format.ParseError: 6:7 : Message type "google.privacy.dlp.v2.Container" has no field named "type".
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.