From 70f83326ef4f30229837973626c91e4bfe5aa08f Mon Sep 17 00:00:00 2001 From: Ravi Khadiwala Date: Fri, 17 Jul 2026 12:00:03 -0500 Subject: [PATCH] Make log stripping more consistent --- .../whispersystems/textsecuregcm/captcha/CaptchaChecker.java | 2 +- .../textsecuregcm/push/PushNotificationManager.java | 4 ++-- .../org/whispersystems/textsecuregcm/storage/Accounts.java | 4 ++-- .../subscriptions/GooglePlayBillingManager.java | 1 - .../org/whispersystems/textsecuregcm/util/HeaderUtils.java | 5 +++-- .../util/logging/LoggingUnhandledExceptionMapper.java | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/captcha/CaptchaChecker.java b/service/src/main/java/org/whispersystems/textsecuregcm/captcha/CaptchaChecker.java index 3f4aafd69..ef1287712 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/captcha/CaptchaChecker.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/captcha/CaptchaChecker.java @@ -100,7 +100,7 @@ public class CaptchaChecker { final Set allowedSiteKeys = client.validSiteKeys(parsedAction); if (!allowedSiteKeys.contains(siteKey)) { - logger.debug("invalid site-key {}, action={}, token={}", siteKey, action, token); + logger.debug("invalid site-key {}, action={}", siteKey, action); Metrics.counter(INVALID_SITEKEY_COUNTER_NAME, "action", action).increment(); throw new InvalidCaptchaArgumentException("invalid captcha site-key"); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java index 76b1bec23..9588d9fec 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java @@ -164,8 +164,8 @@ public class PushNotificationManager { result.unregisteredTimestamp()); } } else { - logger.debug("Failed to deliver {} push notification to {} ({})", - pushNotification.notificationType(), pushNotification.deviceToken(), pushNotification.tokenType(), + logger.debug("Failed to deliver {} push notification to token of type {}", + pushNotification.notificationType(), pushNotification.tokenType(), throwable); Metrics.counter(FAILED_NOTIFICATION_COUNTER_NAME, "cause", throwable.getClass().getSimpleName()).increment(); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java index cf0e419cd..ef58bcbc2 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java @@ -390,8 +390,8 @@ public class Accounts { writeItems.add(phoneNumberConstraintPut); } else { log.error("Reclaiming account with a non-equivalent phone number. Old account {}:{}:{}, new account {}:{}:{}", - existingAccount.getUuid(), existingAccount.getNumber(), existingAccount.getPhoneNumberIdentifier(), - accountToCreate.getUuid(), accountToCreate.getNumber(), accountToCreate.getPhoneNumberIdentifier()); + existingAccount.getUuid(), redactPhoneNumber(existingAccount.getNumber()), existingAccount.getPhoneNumberIdentifier(), + accountToCreate.getUuid(), redactPhoneNumber(accountToCreate.getNumber()), accountToCreate.getPhoneNumberIdentifier()); throw new IllegalArgumentException("reclaimed accounts must have equivalent phone numbers"); } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java index b899fe81a..b6b0b13b8 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java @@ -285,7 +285,6 @@ public class GooglePlayBillingManager implements SubscriptionPaymentProcessor { .orElse(AcknowledgementState.UNSPECIFIED); if (acknowledgementState != AcknowledgementState.ACKNOWLEDGED) { // We should only ever generate receipts for a stored and acknowledged token. - logger.error("Tried to fetch receipt for purchaseToken {} that was never acknowledged", purchaseToken); throw new IllegalStateException("Tried to fetch receipt for purchaseToken that was never acknowledged"); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/util/HeaderUtils.java b/service/src/main/java/org/whispersystems/textsecuregcm/util/HeaderUtils.java index 876b0496c..5ce7a0fcb 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/util/HeaderUtils.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/util/HeaderUtils.java @@ -109,8 +109,9 @@ public final class HeaderUtils { Tag.of("path", containerRequestContext.getUriInfo().getPath()))) .increment(); logger.debug("Could not get acceptable languages; Accept-Language: {}; User-Agent: {}", - containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE), - userAgent, + // Strip any control codes to avoid any weird formatting with console loggers + containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE).replaceAll("\\p{Cntrl}", ""), + userAgent.replaceAll("\\p{Cntrl}", ""), e); return List.of(); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/util/logging/LoggingUnhandledExceptionMapper.java b/service/src/main/java/org/whispersystems/textsecuregcm/util/logging/LoggingUnhandledExceptionMapper.java index 153b00711..307f3f435 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/util/logging/LoggingUnhandledExceptionMapper.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/util/logging/LoggingUnhandledExceptionMapper.java @@ -57,7 +57,8 @@ public class LoggingUnhandledExceptionMapper extends LoggingExceptionMapper