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 {