google-cloud-php icon indicating copy to clipboard operation
google-cloud-php copied to clipboard

DEPRECATED warnings when calling getName() on a Secret or SecretVersion

Open smoopins opened this issue 1 year ago • 5 comments

Environment details

  • OS: MacOS Sonoma 14.5 (M1 series)
  • PHP version: 8.2.21
  • Package name and version: cloud-secret-manager: v1.15.2

Steps to reproduce

Call the getName() method of either a Secret or a SecretVersion.

Code example

        $projectId = 'beetlejuice-example';
        $client = new SecretManagerServiceClient();
        $parent = $client->projectName($projectId);

        $secretId = 'harry-belafonte-example';
        $createSecretRequest = (new CreateSecretRequest())
            ->setParent($parent)
            ->setSecretId($secretId)
            ->setSecret(new Secret([
                'replication' => new Replication([
                    'automatic' => new Automatic(),
                ]),
            ]));

        $secret = $this->client->createSecret($createSecretRequest);
        echo $secret->getName();

The above code outputs many copies of the following pair of deprecation warnings:

   DEPRECATED  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php on line 1890.


   DEPRECATED  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in vendor/google/protobuf/src/Google/Protobuf/Internal/GPBJsonWire.php on line 23.

smoopins avatar Aug 02 '24 16:08 smoopins

I believe this is the same issue as we've documented in https://github.com/protocolbuffers/protobuf/issues/13428

I will try to fix this shortly

bshaffer avatar Aug 08 '24 17:08 bshaffer

This has been fixed in the main branch of protobuf, and will be fixed in the next protobuf release (https://github.com/protocolbuffers/protobuf/commit/6d84da5e2d42a8c83373c0bc6d7ed0ca6f78aade)

bshaffer avatar Aug 20 '24 16:08 bshaffer

This should be fixed in this repo by the end of the week

bshaffer avatar May 13 '25 23:05 bshaffer

These are now fixed in the latest version

bshaffer avatar May 20 '25 20:05 bshaffer

Reopening as this actually seems to be an issue in the protobuf library and requires more consideration

bshaffer avatar May 20 '25 21:05 bshaffer

Hmm, I can't duplicate this, but looking at these lines, they imply that null is being passed to strlen in the protobuf core library. This shouldn't be happening, and I'm not sure what the implications of this are.

To fix this in protobuf, the values being passed into strlen could be cast to string, so if they're null, they won't output that deprecation. But I find it odd that those values would be null...

  • in GPBJsonWire, things would likely fail when $field_name is null
  • in Message, I'm not sure which instance of strlen is throwing the error (because the line number is off), but they seem equally important.

Closing this for now as I can't duplicate it. Please open again on the protobuf repo and assign to me if you continue to experience the issue. And please provide the version of protobuf you're using.

bshaffer avatar Sep 04 '25 17:09 bshaffer