fix(backups): pin a single bracket-free IP for mc --resolve

S3 backup uploads fail when the endpoint has an AAAA record: mc parses
--resolve values with netip.ParseAddr and rejects the bracketed IPv6
form. Its resolver map also keeps only one IP per host, so emit a single
entry, preferring IPv4, without brackets.
This commit is contained in:
Marvin committed 2026-07-24 07:24:44 +02:00
1 parent f06bacc8e0
commit 12033e8091
2 files changed
+23 -3

No files matched your search

+10 -3
View File
@@ -134,10 +134,17 @@ class SafeWebhookUrl implements ValidationRule
return [];
}
return array_map(
fn (string $ip): string => sprintf('%s:%d=%s', $target['host'], $target['port'], filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? '['.$ip.']' : $ip),
// The MinIO client keeps one --resolve IP per host and parses it with Go's
// netip.ParseAddr, which rejects bracketed IPv6. Emit a single entry, preferring
// IPv4 for reachability, without brackets.
$preferredIps = array_values(array_filter(
$target['ips'],
);
fn (string $ip): bool => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false,
));
$ip = $preferredIps[0] ?? $target['ips'][0];
return [sprintf('%s:%d=%s', $target['host'], $target['port'], $ip)];
}
public static function redactedUrlForLog(string $url): string