dns_infomaniak: log zones response and fail early in _get_zone

The sed in _get_zone passed the raw JSON through when the response
contained no [{"fqdn":", so an API error turned the zone into "{" and
the failure only surfaced later as POST /2/zones/{/records
"method_not_found". Log the response at debug2, error out on
non-success results, and parse fqdn position-independently.

https://github.com/acmesh-official/acme.sh/issues/6851
This commit is contained in:
neil 2026-07-13 08:30:43 +08:00
parent 17964cfd6e
commit 020123d812

View file

@ -182,7 +182,11 @@ dns_infomaniak_rm() {
_get_zone() {
domain="$1"
# Whatever the domain is, you can get the fqdn with the following.
# shellcheck disable=SC1004
response=$(_get "${INFOMANIAK_API_URL}/2/domains/${domain}/zones" | sed 's/.*\[{"fqdn"\:"\(.*\)/\1/')
echo "${response%%\"*}"
response=$(_get "${INFOMANIAK_API_URL}/2/domains/${domain}/zones")
_debug2 "_get_zone response" "$response"
if ! _contains "$response" '"result":"success"'; then
_err "cannot get zones for ${domain}, response: ${response}"
return 1
fi
echo "$response" | _egrep_o '"fqdn" *: *"[^"]*"' | _head_n 1 | cut -d '"' -f 4
}