Skip to content

Modified reserved word field names included in field masks. #227

Closed
@BenRKarl

Description

@BenRKarl

I'm not sure whether this is an issue with this library, the generator or the field mask helper, but it seems to be incorrect behavior that's blocking for Ads users, unless there's a workaround or other solution I'm not aware of:

Environment details

  • Programming language: Python
  • OS: gLinux
  • Language runtime version: 3.7.0
  • Package version: 1.18.1

Steps to reproduce

Assuming we have a protobuf definition like the following:

message HasType {
  string type = 1;
}

We'll have a generated Python class similar to:

class HasType(proto.Message):
    type_ = proto.Field(proto.STRING, number=1,)

Where type has been modified to type_.

Normally setting type_ isn't a problem, the issue is that this modified field name gets leaked into field masks, which are revoked by the API because it doesn't match the protobuf definition. This prevents users from executing update requests where the type field on any object has been modified.

Here's a short script to reproduce:

from google.api_core import protobuf_helpers
import proto

class HasType(proto.Message):
    type_ = proto.Field(proto.STRING, number=1,)

ht = HasType()
ht.type_ = "has type"

fm = protobuf_helpers.field_mask(None, ht._pb)

print(fm.paths[0])
# >>> "type_"

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions