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:
beatz174-bit authored and GitHub committed 2026-04-29 14:45:42 +10:00
commit ee7a24a0da
2 files changed
+39 -2

No files matched your search

+3 -2
View File
@@ -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 {