Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FieldMasks::getFieldValue fails for enums #1037

Open
mrpavlikov opened this issue Jul 18, 2024 · 1 comment
Open

FieldMasks::getFieldValue fails for enums #1037

mrpavlikov opened this issue Jul 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working triage Need triage

Comments

@mrpavlikov
Copy link

mrpavlikov commented Jul 18, 2024

Your client library and Google Ads API versions:

  • Client library version: v22.1.0
  • Google Ads API version: V16

Your environment:

  • The PHP version: 8.0.30
  • The name and version of the operating system: Linux a59f316b98dd 6.8.0-38-generic #38-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:25:01 UTC 2024 x86_64
  • Whether the PHP Extension protobuf is used or not: No.
  • Whether the PHP Extension grpc is used or not: No.
  • The type of transport being used (grpc or rest): Rest

Description of the bug:

I've been retrieving account change history like example suggests: https://developers.google.com/google-ads/api/samples/get-change-details#php

Getting following error:

Call to a member function getName() on null {"exception":"[object] (Error(code: 0): Call to a member function getName() on null at /www/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Util/FieldMasks.php:307

I have change event in path geo_target_type_setting.positive_geo_target_type and new value is 7. Code that gives error FieldMasks.php:307 uses getValueDescriptorByIndex($index), but 7 is not the index, it is number. Your enum has "holes" and number does not match index, see PositiveGeoTargetType.

The only workaround I can think of is modifying my instance of lib for now, so it does this:

$property = new \ReflectionProperty(get_class($fieldDescriptor->getEnumType()), 'internal_desc');
$property->setAccessible(true);
$fieldValue = $property->getValue($fieldDescriptor->getEnumType())->getValueByNumber($fieldValue)->getName();

Expected behavior:

Returns PRESENCE

@mrpavlikov mrpavlikov added bug Something isn't working triage Need triage labels Jul 18, 2024
@fiboknacky
Copy link
Member

Could you please post on the Google Ads API forum and refer to this issue?
Please tell the agent on the forum that you want to privately share information with the PHP client library owner.
They'll guide you how to Reply privately to them. Share your customer ID there, so I can try reproducing this issue.
Thanks!

@fiboknacky fiboknacky self-assigned this Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Need triage
Projects
None yet
Development

No branches or pull requests

2 participants