diff --git a/app/Exceptions/Social/SocialPublishException.php b/app/Exceptions/Social/SocialPublishException.php index 8d007728..2af28382 100644 --- a/app/Exceptions/Social/SocialPublishException.php +++ b/app/Exceptions/Social/SocialPublishException.php @@ -28,7 +28,7 @@ public function context(): array 'category' => $this->category->value, 'platform_error_code' => $this->platformErrorCode, 'user_message' => $this->userMessage, - 'raw_response' => $this->rawResponse !== null ? TokenRedactor::redact($this->rawResponse) : null, + 'raw_response' => TokenRedactor::redact($this->rawResponse), ]; } diff --git a/app/Services/Social/TokenRedactor.php b/app/Services/Social/TokenRedactor.php index bc154048..8da132e5 100644 --- a/app/Services/Social/TokenRedactor.php +++ b/app/Services/Social/TokenRedactor.php @@ -12,8 +12,12 @@ */ class TokenRedactor { - public static function redact(string $body): string + public static function redact(?string $body): ?string { + if ($body === null) { + return null; + } + return preg_replace( [ '/access_token=([^&"\s]+)/',