gandi: Fix processing of PUT error responses

Before, the returned JSON wasn't even parsed -- the error handling
code was reusing the parsed response from the earlier `GET`.  Also, it
was reading object properties that were not documented in the Gandi
API documentation.
This commit is contained in:
Richard Hansen 2024-07-28 02:43:56 -04:00
parent 06c3dd5825
commit 0b30df4b69
2 changed files with 7 additions and 7 deletions

View file

@ -142,6 +142,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
[#719](https://github.com/ddclient/ddclient/pull/719)
* `yandex`: Errors are now retried.
[#719](https://github.com/ddclient/ddclient/pull/719)
* `gandi`: Fixed handling of error responses.
[#721](https://github.com/ddclient/ddclient/pull/721)
## 2023-11-23 v3.11.2

View file

@ -6952,14 +6952,12 @@ sub nic_gandi_update {
);
if (!header_ok($h, $reply)) {
$config{$h}{"status-$ipv"} = "bad";
if (defined($response->{status}) && $response->{status} eq "error") {
my @errors;
for my $err (@{$response->{errors}}) {
push(@errors, $err->{description});
}
failed("$h: " . join(", ", @errors));
$reply =~ s/^.*?\n\n//s;
my $response = eval { decode_json($reply) };
if (ref($response) eq 'HASH' && ($response->{message} // '') ne '') {
failed("$h: $response->{message}");
} else {
failed("$h: unexpected service response");
failed("$h: unexpected error response: $reply");
}
next;
}