From 0a20ba6fa3c2cd52271c24754105279cca89ae9d Mon Sep 17 00:00:00 2001 From: beatz174-bit Date: Wed, 29 Apr 2026 14:41:32 +1000 Subject: [PATCH] Fix dynamic A TTL update fallback for generic validation error --- internal/provider/resource_dns_record.go | 5 +-- internal/provider/resource_dns_record_test.go | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/internal/provider/resource_dns_record.go b/internal/provider/resource_dns_record.go index b0790ff..1c954fe 100644 --- a/internal/provider/resource_dns_record.go +++ b/internal/provider/resource_dns_record.go @@ -587,11 +587,12 @@ func isUnsupportedEmptyContentError(err error) bool { if normalizedType != "validation exception" { return false } - normalizedMessage := strings.ToLower(strings.TrimSpace(apiErr.Message)) + normalizedMessage := strings.ToLower(strings.TrimSpace(strings.TrimSuffix(apiErr.Message, "."))) return strings.Contains(normalizedMessage, "content is required") || strings.Contains(normalizedMessage, "ipv4address is required") || strings.Contains(normalizedMessage, "ipv6address is required") || - strings.Contains(normalizedMessage, "invalid ip address") + strings.Contains(normalizedMessage, "invalid ip address") || + normalizedMessage == "invalid" } func (r *dnsRecordResource) applyDynamicBootstrapFallback(ctx context.Context, domainID int64, req dynuclient.CreateDNSRecordRequest, diagnostics *diag.Diagnostics) (dynuclient.CreateDNSRecordRequest, bool) { diff --git a/internal/provider/resource_dns_record_test.go b/internal/provider/resource_dns_record_test.go index 9424d78..5b83406 100644 --- a/internal/provider/resource_dns_record_test.go +++ b/internal/provider/resource_dns_record_test.go @@ -228,6 +228,24 @@ func TestIsUnsupportedEmptyContentError(t *testing.T) { }, want: true, }, + { + name: "status 505 generic invalid with period", + err: &dynuclient.APIError{ + StatusCode: 505, + Type: "Validation Exception", + Message: "Invalid.", + }, + want: true, + }, + { + name: "status 505 generic invalid without period", + err: &dynuclient.APIError{ + StatusCode: 505, + Type: "Validation Exception", + Message: "Invalid", + }, + want: true, + }, { name: "status 505 unrelated message", err: &dynuclient.APIError{ @@ -246,6 +264,24 @@ func TestIsUnsupportedEmptyContentError(t *testing.T) { }, want: false, }, + { + name: "status 500 generic invalid", + err: &dynuclient.APIError{ + StatusCode: 500, + Type: "Validation Exception", + Message: "Invalid.", + }, + want: false, + }, + { + name: "status 505 non validation generic invalid", + err: &dynuclient.APIError{ + StatusCode: 505, + Type: "Some Other Exception", + Message: "Invalid.", + }, + want: false, + }, } for _, tc := range tests {