aws / aws-sdk-php

Official repository of the AWS SDK for PHP (@awsforphp)
http://aws.amazon.com/sdkforphp
Apache License 2.0
6.04k stars 1.23k forks source link

verifyDomainDkim method of SES Client returns validation error #2880

Closed onurkose closed 9 months ago

onurkose commented 9 months ago

Describe the bug

Documentation suggests using the method like this:

$result = $sesClient->verifyDomainDkim(['IdentityDomain' => 'example.com']);

Method's validation rule also expects IdentityDomain key to be exists.

The endpoint returns this error:

ValidationError (client): 1 validation error detected: Value null at 'domain' failed to satisfy constraint: Member must not be null

Expected Behavior

Returns the expected response such as:

{
    "DkimTokens": [
        "..."
    ]
}

Current Behavior

This is ok with the SDK validation:

$result = $sesClient->verifyDomainDkim(['IdentityDomain' => 'example.com']);

If I try passing only domain (as the error suggests) key:

$result = $sesClient->verifyDomainDkim(['domain' => 'example.com']);

then it throws this exception:

Found 1 error while validating the input provided for the VerifyDomainDkim operation:
[IdentityDomain] is missing and is a required parameter

I've also tried disabling SDK validation like this:

$client = new SesClient([
    'credentials' => ...,
    'region' => ...,
    'validate' => false,
]);

then it goes back to the beginning and returns the same error response:

ValidationError (client): 1 validation error detected: Value null at 'domain' failed to satisfy constraint: Member must not be null

Here are some logs from when debug mode was enabled:

-> Entering step build, name 'builder'
  ...
  request.body was set to Action=VerifyDomainDkim&Version=2010-12-01&IdentityDomain=example.com
  request.scheme was set to https

-> Entering step build, name 'ApiCallMonitoringMiddleware'

Reproduction Steps

  1. Create a domain identity (example.com) in AWS SES with any of the DKIM identity type (Easy or BYODKIM)
  2. First use aws cli to verify DKIM records: aws ses verify-domain-dkim --domain example.com --region us-east-1
  3. It will return a JSON response with the DkimTokens key.
  4. Then try the same with the AWS PHP SDK - SES Client's verifyDomainDkim method.

Possible Solution

No response

Additional Information/Context

In the meantime PHP SDK V2 and V3 documentation suggests using Domain as key when using this method.

SDK version used

aws-sdk-php 3.299.0 | aws/aws-sdk-php-symfony 2.7.0

Environment details (Version of PHP (php -v)? OS name and version, etc.)

PHP 8.2.9, MacOS 14.3.1, Env: Docker php:8.2-fpm-alpine

yenfryherrerafeliz commented 9 months ago

Hi @onurkose, what I think that could be happening here is that for some reason your PHP SDK version is pinned to an older version where IdentityDomain was the expected parameter. The reason I think this is the issue is because in the current SDK version there is not a modeled parameter IdentityDomain for that operation, which we can confirm here in the input shape expected for this request. So there should not be a validation expecting that parameter, unless is an older version. There are different ways for confirming this:

Please make sure that when you do those tests you provided that parameter as 'Domain' and not 'domain'.

I look forward to your response.

Thanks!

onurkose commented 9 months ago

It's so strange. When I run the composer show command I receive the version as 3.299.0 and the line is like this:

'required' => [ 'IdentityDomain', ]

But even when I check the v3.299.0 tag, it's defined as Domain over there.

Deleting the lock file and composer update command fixed the issue.

Thanks a lot.

yenfryherrerafeliz commented 9 months ago

@onurkose, you are very welcome. I do not know either why you got that behavior, but I am glad it is resolved now. Please open a new issue for anything else that we can help you with.

Thanks!

github-actions[bot] commented 9 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.