Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/pdns/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func FriendlyMessage(err error) string {
case strings.Contains(detail, "RRset") && strings.Contains(detail, "IN ALIAS"):
return "An ALIAS record conflicts with an existing record at this name."
case apiErr.Status == 422:
// Surface the specific PowerDNS rejection reason when it doesn't match a
// known pattern; without it the reason is only visible in operator logs.
if detail != "" {
return "The DNS record was rejected as invalid: " + detail
}
return "The DNS record was rejected as invalid. Check the record type and value."
case apiErr.Status == 404:
return "The DNS zone could not be found. It may still be provisioning."
Expand Down
4 changes: 2 additions & 2 deletions internal/pdns/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func TestFriendlyMessage(t *testing.T) {
want: "The DNS record was rejected as invalid. Check the record type and value.",
},
{
name: "422 unknown body falls back to generic 422 message",
name: "422 unknown body surfaces the specific pdns detail",
err: &pdnsAPIError{Status: 422, Body: `{"error": "Some other validation error"}`},
want: "The DNS record was rejected as invalid. Check the record type and value.",
want: "The DNS record was rejected as invalid: Some other validation error",
},
{
name: "404",
Expand Down
Loading