diff --git a/.changelog/3177.txt b/.changelog/3177.txt new file mode 100644 index 0000000000..215c1c0dca --- /dev/null +++ b/.changelog/3177.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_cos_bucket: optimize `acl_body` verification logic +``` diff --git a/tencentcloud/services/cos/resource_tc_cos_bucket.go b/tencentcloud/services/cos/resource_tc_cos_bucket.go index f045493a1e..afd2aedf6c 100644 --- a/tencentcloud/services/cos/resource_tc_cos_bucket.go +++ b/tencentcloud/services/cos/resource_tc_cos_bucket.go @@ -1963,9 +1963,14 @@ func ACLBodyDiffFunc(olds, news string, d *schema.ResourceData) (result bool) { newOwnerId := newOwner.SelectElement("ID") newOwnerName := newOwner.SelectElement("DisplayName") + if oldOwnerId == nil || newOwnerId == nil { + log.Println("[CRITAL]oldOwnerId or newOwnerId is nil: return false.") + return false + } + // diff: Owner element - if oldOwnerId.Text() != newOwnerId.Text() || oldOwnerName.Text() != newOwnerName.Text() { - log.Printf("[CRITAL]OwnerId[old:%s, new:%s] or OwnerName[old:%s, new:%s] not equal: return false.\n", oldOwnerId.Text(), newOwnerId.Text(), oldOwnerName.Text(), newOwnerName.Text()) + if oldOwnerId.Text() != newOwnerId.Text() { + log.Printf("[CRITAL]OwnerId[old:%s, new:%s] not equal: return false.\n", oldOwnerId.Text(), newOwnerId.Text()) return false }