-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
Hi,
When submitting with the optional "Filter" settings, the route "PutBucketNotificationConfiguration" returns a 400 "MalformedXML" error:
'Filter' => [
'Key' => [
'FilterRules' => [
[
'Name' => 'prefix',
'Value' => 'images/'
]
]
]
]
Without the "Filter" settings it works however.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
The route "PutBucketNotificationConfiguration" should update the notifications configuration of an S3 bucket with specific "Filter" settings.
Current Behavior
When submitting "Filter" settings according to the structure mentioned in the docs, the route returns a 400 "MalformedXML" error.
Without the "Filter" settings it works however.
Reproduction Steps
Submit like route docs say, with additional "Filter" settings:
'Filter' => [
'Key' => [
'FilterRules' => [
[
'Name' => 'prefix',
'Value' => 'images/'
]
]
]
]
Possible Solution
When turning on the debug flag on the S3Client I can see the submitted XML has these tags: <Filter><Key>... while the docs say it must be like <Filter><S3Key>.... So I've tried changing my PHP from 'Key' => [...] to 'S3Key' => [...] but that results in a clear 400 with an explicit message that the key is invalid.
The config in the SDK PHP seems to have the right locationName in the file /src/data/s3/2006-03-01/api-2.json.php:
'NotificationConfigurationFilter' => [ 'type' => 'structure', 'members' => [ 'Key' => [ 'shape' => 'S3KeyFilter', 'locationName' => 'S3Key', ], ], ]
Version 3.351.0 does handle "Filter" correctly, but later versions don't. Probably due to change in 3.351.11:
c56f413
Additional Information/Context
Also see duplicate on re:Post:
https://repost.aws/questions/QUpHMmfR93SXOyJNHCgFJn2w/method-putbucketnotificationconfiguration-returns-unexpected-400-malformedxml-error-using-aws-sdk-php-when-including-filter-options
SDK version used
3.366.2
Environment details (Version of PHP (php -v)? OS name and version, etc.)
PHP 8.3 / Ubuntu 24.04