error putting Object Storage lifecycle: MalformedXML: Only one field is accepeted in Filter, either Prefix, Tag or And #2420
Labels
bug
object
Object storage issues, bugs and feature requests
priority:highest
Bugs filled by customers, security issues
Community Note
Terraform Version
1.5.7 with Scaleway provider version 2.37.0
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
The bucket with the desired lifecycle rule should be created or if the bucket exists (my case) the lifecycle rule should be created.
Actual Behavior
I have the error:
Error: error putting Object Storage lifecycle: MalformedXML: Only one field is accepeted in Filter, either Prefix, Tag or And status code: 400, request id: txg6aff11ceeac94af797db-XXXXXXXXXXXX, host id: txg6aff11ceeac94af797db-XXXXXXXXXXXX
Steps to Reproduce
terraform apply
Important Factoids
I took a look in the code and the issue comes from the code in https://github.com/scaleway/terraform-provider-scaleway/blob/master/scaleway/resource_object_bucket.go#L353 lines 353-368:
In fact, if I add two or more tags in the lifecycle rule there is no error.
Basically, if I have the following lifecycle declaration:
The second condition in the code above (
if len(tags) > 1
) is not true and theLifecycleRuleAndOperator
is not used what causes the issue.So, we have the following scenarios:
len(tags) >= 0 && len(prefix) == 0 --> Works
len(tags) == 0 && len(prefix) >= 1 --> Works
len(tags) > 1 && len(prefix) >= 1 --> Works
len(tags) == 1 && len(prefix) >= 1 --> Fails
References
This problem is related to the use of the LifecycleRuleAndOperator
Please see, for example: https://stackoverflow.com/questions/69579127/how-can-i-update-a-lifecycle-configuration-with-a-filter-based-on-both-prefix-an
The text was updated successfully, but these errors were encountered: