Expose sanitized Portainer connection errors

This commit is contained in:
Hermes Agent
2026-09-20 15:35:29 +00:00
parent 40cea4ca65
commit f45cc35bf7
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -195,7 +195,9 @@ function pnpaas_portainer_request(string $path, string $method = 'GET', ?array $
curl_close($handle);
if ($body === false || $error !== '') {
throw new RuntimeException('Portainer ist nicht erreichbar.');
$detail = trim($error);
$detail = preg_replace('/(?:X-API-Key|Authorization|Bearer)\s*:\s*[^\s,;]+/i', '[credential redacted]', $detail) ?? $detail;
throw new RuntimeException('Portainer ist nicht erreichbar' . ($detail !== '' ? ': ' . substr($detail, 0, 400) : '.'));
}
if ($status < 200 || ($status >= 300 && $status !== 304)) {
$detail = trim(preg_replace('/\s+/', ' ', (string)$body) ?? '');