From e7916302ba1857a5230a63f9ff2e5269ffba065c Mon Sep 17 00:00:00 2001 From: Ravi Khadiwala Date: Tue, 6 Oct 2026 15:37:55 -0500 Subject: [PATCH] Remove impossible set-level response case --- .../grpc/SubscriptionsGrpcService.java | 4 ++-- .../proto/org/signal/chat/subscriptions.proto | 19 ++++++++----------- .../grpc/SubscriptionsGrpcServiceTest.java | 4 +--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java index 5f9867083..d3c8e4ec5 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java @@ -357,8 +357,8 @@ public class SubscriptionsGrpcService extends SimpleSubscriptionsGrpc.Subscripti return SetSubscriptionLevelResponse.newBuilder() .setInvalidLevelTransition(FailedPrecondition.newBuilder().build()).build(); } catch (final PurchaseProcessorConflictException e) { - return SetSubscriptionLevelResponse.newBuilder().setSubscriptionProcessorConflict( - FailedPrecondition.newBuilder().setDescription(e.errorDetail().orElse("")).build()).build(); + // We just looked up the subscription processor from the database, a conflict is not possible + throw new IllegalStateException(e); } } diff --git a/service/src/main/proto/org/signal/chat/subscriptions.proto b/service/src/main/proto/org/signal/chat/subscriptions.proto index a9308d5eb..eaecbece2 100644 --- a/service/src/main/proto/org/signal/chat/subscriptions.proto +++ b/service/src/main/proto/org/signal/chat/subscriptions.proto @@ -312,25 +312,22 @@ message SetSubscriptionLevelResponse { google.protobuf.Empty success = 1; // The subscriber did not exist errors.NotFound subscriber_not_found = 2 [(tag.reason) = "subscriber_not_found"]; - // New payment processor does not match existing processor associated with - // the subscription - errors.FailedPrecondition subscription_processor_conflict = 3 [(tag.reason) = "subscription_processor_conflict"]; // No payment method has been created for the subscriber - errors.FailedPrecondition payment_method_not_set_up = 4 [(tag.reason) = "payment_method_not_set_up"]; + errors.FailedPrecondition payment_method_not_set_up = 3 [(tag.reason) = "payment_method_not_set_up"]; // The payment processor does not support this operation - errors.FailedPrecondition unsupported_operation = 5 [(tag.reason) = "unsupported_operation"]; + errors.FailedPrecondition unsupported_operation = 4 [(tag.reason) = "unsupported_operation"]; // The requested level was invalid - errors.FailedPrecondition unsupported_level = 6 [(tag.reason) = "unsupported_level"]; + errors.FailedPrecondition unsupported_level = 5 [(tag.reason) = "unsupported_level"]; // The requested currency was invalid - errors.FailedPrecondition unsupported_currency = 7 [(tag.reason) = "unsupported_currency"]; + errors.FailedPrecondition unsupported_currency = 6 [(tag.reason) = "unsupported_currency"]; // The card could not be charged - errors.FailedPrecondition payment_requires_action = 8 [(tag.reason) = "payment_requires_action"]; + errors.FailedPrecondition payment_requires_action = 7 [(tag.reason) = "payment_requires_action"]; // Cannot transition from existing level to the requested level - errors.FailedPrecondition invalid_level_transition = 9 [(tag.reason) = "invalid_level_transition"]; + errors.FailedPrecondition invalid_level_transition = 8 [(tag.reason) = "invalid_level_transition"]; // The idempotency key was invalid or re-used with a modified request - errors.FailedPrecondition invalid_idempotency_key = 10 [(tag.reason) = "invalid_idempotency_key"]; + errors.FailedPrecondition invalid_idempotency_key = 9 [(tag.reason) = "invalid_idempotency_key"]; // The payment failed; see charge failure details - ChargeFailure charge_failure = 11 [(tag.reason) = "charge_failure"]; + ChargeFailure charge_failure = 10 [(tag.reason) = "charge_failure"]; } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java index e34cd2942..0bcddb329 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java @@ -497,9 +497,7 @@ public class SubscriptionsGrpcServiceTest extends Arguments.of(new PurchasePaymentRequiresActionException(), SetSubscriptionLevelResponse.ResponseCase.PAYMENT_REQUIRES_ACTION), Arguments.of(new PurchaseInvalidLevelException(), - SetSubscriptionLevelResponse.ResponseCase.INVALID_LEVEL_TRANSITION), - Arguments.of(new PurchaseProcessorConflictException(), - SetSubscriptionLevelResponse.ResponseCase.SUBSCRIPTION_PROCESSOR_CONFLICT) + SetSubscriptionLevelResponse.ResponseCase.INVALID_LEVEL_TRANSITION) ); }