Skip to content

Unrecognized fields when copying a field mask when trying to update a custom audience #454

@caspercrause

Description

@caspercrause

Describe the bug:
Attempted to update a custom audience, had to copy a field mask with

fm = protobuf_helpers.field_mask(None,custom_audience._pb) # Field Mask
         
  custom_audience_operation.update_mask.CopyFrom(fm) # Update Field Mask

This created an invalid field called type_
When attempting to mutate:

custom_audience_response = custom_audience_service.mutate_custom_audiences(customer_id=customer_id, operations=Operation)

The following error occured:

WARNING:google.ads.googleads.client:Request made: ClientCustomerId: REDACTED, Host: googleads.googleapis.com, Method: /google.ads.googleads.v8.services.CustomAudienceService/MutateCustomAudiences, RequestId: tEtk-QUSW2PFBpQ7idVkTg, IsFault: True, FaultMessage: The field mask contained an invalid field: 'type_'.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

Steps to Reproduce:
You will need to update an existing custom audience – currently there exists no such script – I created my own. It worked under google-ads==9.0.0 and API version (V6) bot not with API version (V8) and google-ads==12.0.0
But in short:

           # Create a custom audience operation.
            custom_audience_operation = client.get_type("CustomAudienceOperation")
            # Update a custom audience
            custom_audience = custom_audience = custom_audience_operation.update
            custom_audience.resource_name = custom_audience_service.custom_audience_path(customer_id, __id__)
            custom_audience.name = __audiencename__
            # What will the Audience Type be ?
            CustomAudienceEnum = client.get_type("CustomAudienceTypeEnum")
            member_type_enum   = client.get_type("CustomAudienceMemberTypeEnum").CustomAudienceMemberType
            custom_audience.type_ = CustomAudienceEnum.CustomAudienceType.SEARCH
            member1             = _create_custom_audience_member(client,member_type_enum.KEYWORD)
            member1.keyword = keyword
            custom_audience.members.append(member1)
            fm = protobuf_helpers.field_mask(None,custom_audience._pb) # Field Mask
            # pdb.set_trace()
            custom_audience_operation.update_mask.CopyFrom(fm) # Update Field Mask
            #BREAKS HERE:
            custom_audience_response = custom_audience_service.mutate_custom_audiences(customer_id=customer_id, operations=Operation)


Expected behavior:

print ("Updated custom audience with resource name: "
       f"'{custom_audience_response.results[0].resource_name}'")

Client library version and API version:
Client library version: 12.0.0
Google Ads API version: V8

packages_used.txt

Request/Response Logs:

logs.txt

Anything else we should know about your project / environment:

Metadata

Metadata

Labels

bugSomething isn't workingtriageNew issue; requires attention

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions