Archived
Fix dynamic A TTL update fallback for generic validation error
This commit is contained in:
@@ -587,11 +587,12 @@ func isUnsupportedEmptyContentError(err error) bool {
|
|||||||
if normalizedType != "validation exception" {
|
if normalizedType != "validation exception" {
|
||||||
return false
|
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") ||
|
return strings.Contains(normalizedMessage, "content is required") ||
|
||||||
strings.Contains(normalizedMessage, "ipv4address is required") ||
|
strings.Contains(normalizedMessage, "ipv4address is required") ||
|
||||||
strings.Contains(normalizedMessage, "ipv6address 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) {
|
func (r *dnsRecordResource) applyDynamicBootstrapFallback(ctx context.Context, domainID int64, req dynuclient.CreateDNSRecordRequest, diagnostics *diag.Diagnostics) (dynuclient.CreateDNSRecordRequest, bool) {
|
||||||
|
|||||||
@@ -228,6 +228,24 @@ func TestIsUnsupportedEmptyContentError(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: true,
|
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",
|
name: "status 505 unrelated message",
|
||||||
err: &dynuclient.APIError{
|
err: &dynuclient.APIError{
|
||||||
@@ -246,6 +264,24 @@ func TestIsUnsupportedEmptyContentError(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: false,
|
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 {
|
for _, tc := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user