Archived
Merge pull request #44 from beatz174-bit/codex/fix-dynamic-a-record-ttl-update
Trigger dynamic A fallback on Dynu "Invalid." validation error
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user