Remove impossible set-level response case

This commit is contained in:
Ravi Khadiwala authored and ravi-signal committed 2026-10-07 14:53:28 -05:00
1 parent db00752f3d
commit e7916302ba
3 files changed
+11 -16

No files matched your search

@@ -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);
}
}
@@ -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"];
}
}
@@ -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)
);
}