From 97a77ce23ec56871e3ea805d6160ad130b2f9d04 Mon Sep 17 00:00:00 2001 From: Katherine Yen Date: Tue, 9 Jun 2026 16:26:38 -0400 Subject: [PATCH] Remove duplicate constructor for invalid argument gRPC exception with no details --- .../textsecuregcm/grpc/AccountsGrpcService.java | 2 +- .../textsecuregcm/grpc/GrpcExceptions.java | 14 -------------- .../grpc/ProfileAnonymousGrpcService.java | 4 ++-- .../textsecuregcm/grpc/ProfileGrpcHelper.java | 2 +- .../textsecuregcm/grpc/ProfileGrpcService.java | 4 ++-- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/AccountsGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/AccountsGrpcService.java index 760782551..f1c1eacd8 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/AccountsGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/AccountsGrpcService.java @@ -168,7 +168,7 @@ public class AccountsGrpcService extends SimpleAccountsGrpc.AccountsImplBase { try { usernameHashZkProofVerifier.verifyProof(request.getZkProof().toByteArray(), request.getUsernameHash().toByteArray()); } catch (final BaseUsernameException e) { - throw GrpcExceptions.constraintViolation("Could not verify proof"); + throw GrpcExceptions.invalidArguments("Could not verify proof"); } rateLimiters.getUsernameSetLimiter().validate(authenticatedDevice.accountIdentifier()); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/GrpcExceptions.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/GrpcExceptions.java index 2cc7b4350..bad7976b8 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/GrpcExceptions.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/GrpcExceptions.java @@ -93,20 +93,6 @@ public class GrpcExceptions { .build()); } - /// The RPC argument violated a constraint that was annotated or documented in the service definition. It is always - /// possible to check this constraint without communicating with the chat server. This always represents a client bug - /// or out of date client. - /// - /// @param message Additional context about the constraint violation - /// @return A [StatusRuntimeException] encoding the error - public static StatusRuntimeException constraintViolation(@Nullable final String message) { - return StatusProto.toStatusRuntimeException(com.google.rpc.Status.newBuilder() - .setCode(Status.Code.INVALID_ARGUMENT.value()) - .setMessage(messageOrDefault(message, Status.Code.INVALID_ARGUMENT)) - .addDetails(ERROR_INFO_CONSTRAINT_VIOLATED) - .build()); - } - /// The request has incorrectly set authentication credentials for the RPC. This represents a client bug where the /// authorization header is not correct for the RPC. For example, /// diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java index d94623c86..013e31dfe 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java @@ -77,7 +77,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof case UNIDENTIFIED_ACCESS_KEY -> targetAccount.map(a -> UnidentifiedAccessUtil.checkUnidentifiedAccess(a, request.getUnidentifiedAccessKey().toByteArray())) .orElse(false); - default -> throw GrpcExceptions.constraintViolation("invalid authentication"); + default -> throw GrpcExceptions.invalidArguments("invalid authentication"); }; if (!authorized) { @@ -126,7 +126,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof final ServiceIdentifier targetIdentifier = GrpcServiceIdentifierUtil.fromGrpcServiceIdentifier(request.getRequest().getAccountIdentifier()); if (request.getRequest().getCredentialType() != CredentialType.CREDENTIAL_TYPE_EXPIRING_PROFILE_KEY) { - throw GrpcExceptions.constraintViolation("invalid credential type"); + throw GrpcExceptions.invalidArguments("invalid credential type"); } final Optional maybeAccount = getTargetAccountAndValidateUnidentifiedAccess( diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java index 64a7b670d..7b9c02679 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java @@ -208,7 +208,7 @@ public class ProfileGrpcHelper { profileKeyCredentialResponse = ProfileHelper.getExpiringProfileKeyCredential(new ProfileKeyCredentialRequest(encodedCredentialRequest), new ProfileKeyCommitment(commitment), new ServiceId.Aci(account.getUuid()), zkProfileOperations); } catch (VerificationFailedException | InvalidInputException e) { - throw GrpcExceptions.constraintViolation("invalid credential request"); + throw GrpcExceptions.invalidArguments("invalid credential request"); } return GetExpiringProfileKeyCredentialResult.newBuilder() diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java index 1922adfe4..63bd6604f 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java @@ -257,12 +257,12 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase { private void validateRequest(final SetProfileRequest request) { if (request.getExpectedCurrentDataHash().isEmpty() && request.getCommitment().isEmpty()) { - throw GrpcExceptions.constraintViolation("At least one of expected current data hash and commitment is required"); + throw GrpcExceptions.invalidArguments("At least one of expected current data hash and commitment is required"); } // v1 -> v2 migration if (request.getCommitment().isEmpty()) { - throw GrpcExceptions.constraintViolation("Request must include commitment during migration"); + throw GrpcExceptions.invalidArguments("Request must include commitment during migration"); } }