Skip to content

Commit

Permalink
5098 branch 21 update more invalid params (#7467)
Browse files Browse the repository at this point in the history
* 5098: Add RpcErrorTypes

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestException, apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestException, apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Add JsonRpcParameterException for later use

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update locations for RpcErrorType.INVALID_ACCOUNTS_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Address review comments, apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with changes from branch 1

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update code to use RpcErrorType.INVALID_ADDRESS_HASH_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update plugin-api gradle hash

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Add comment on INVALID_PARAMS_ERROR_CODE

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless on latest changes

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update code to use RpcErrorType.INVALID_ADDRESS_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken unit test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken unit test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with usage of RpcErrorType.INVALID_AUTH_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with usage of RpcErrorType.INVALID_BLOB_COUNT

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with usage of RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with usage of RpcErrorType.INVALID_BLOCK_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with usage of RpcErrorType.INVALID_BLOCK_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with usage of RpcErrorType.INVALID_BLOCK_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update with usage of RpcErrorType.INVALID_BLOCK_COUNT_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken integration test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Add index to exception messages

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: apoply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update BaseJsonRpcProcessor to utilise RpcErrorType from InvalidJsonRpcParameters

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Include parameter index in INVALID_AUTH_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Include parameter index in INVALID_BLOCK_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Include parameter index in INVALID_BLOCK_COUNT_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken integration test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Rename INVALID_AUTH_PARAMS to INVALID_PROPOSAL_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update INVALID_BLOCK_HASH_PARAMS locations

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken unit test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_BLOCK_INDEX

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_BLOCK_NUMBER

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken tests

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_CALL_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_CONSOLIDATION_REQUEST_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_CREATE_PRIVACY_GROUP_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_DATA_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_DEPOSIT_REQUEST_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_ENGINE_PAYLOAD_ATTRIBUTES_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_ENGINE_PAYLOAD_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_ENODE_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_EXTRA_DATA_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_FILTER_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken tests

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update several RpcErrorTypes

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Hopefully fix broken integration test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Hopefully fix broken integration test

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update several more RpcErrorTypes

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_PARAM_COUNT

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_PAYLOAD_ID_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVALID_PENDING_TRANSACTIONS_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorType.INVAlID_PLUGIN_NAME_PARAMS

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken tests

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Update RpcErrorTypes

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Fix broken tests

Signed-off-by: Matilda Clerke <[email protected]>

* 5098: Apply spotless

Signed-off-by: Matilda Clerke <[email protected]>

* Update ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java

Co-authored-by: Sally MacFarlane <[email protected]>
Signed-off-by: Matilda-Clerke <[email protected]>

---------

Signed-off-by: Matilda Clerke <[email protected]>
Signed-off-by: Matilda-Clerke <[email protected]>
Co-authored-by: Sally MacFarlane <[email protected]>
  • Loading branch information
Matilda-Clerke and macfarla authored Aug 16, 2024
1 parent d7041d4 commit 8523ed0
Show file tree
Hide file tree
Showing 29 changed files with 244 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,15 @@ public JsonRpcResponse response(final JsonRpcRequestContext request) {
"Invalid highest block parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

final Optional<List<Double>> maybeRewardPercentiles =
request.getOptionalParameter(2, Double[].class).map(Arrays::asList);
final Optional<List<Double>> maybeRewardPercentiles;
try {
maybeRewardPercentiles = request.getOptionalParameter(2, Double[].class).map(Arrays::asList);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid reward percentiles parameter (index 2)",
RpcErrorType.INVALID_REWARD_PERCENTILES_PARAMS,
e);
}

final BlockHeader chainHeadHeader = blockchain.getChainHeadHeader();
final long chainHeadBlockNumber = chainHeadHeader.getNumber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
}

private List<UInt256> getStorageKeys(final JsonRpcRequestContext request) {
return Arrays.stream(request.getRequiredParameter(1, String[].class))
.map(UInt256::fromHexString)
.collect(Collectors.toList());
try {
return Arrays.stream(request.getRequiredParameter(1, String[].class))
.map(UInt256::fromHexString)
.collect(Collectors.toList());
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid storage keys parameters (index 1)", RpcErrorType.INVALID_STORAGE_KEYS_PARAMS, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ protected String resultByBlockHash(final JsonRpcRequestContext request, final Ha
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final UInt256 position = request.getRequiredParameter(1, UInt256Parameter.class).getValue();
final UInt256 position;
try {
position = request.getRequiredParameter(1, UInt256Parameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid position parameter (index 1)", RpcErrorType.INVALID_POSITION_PARAMS, e);
}
return blockchainQueries
.get()
.storageAt(address, position, blockHash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String hashRate;
try {
hashRate = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) {
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid hash rate parameter (index 0)", RpcErrorType.INVALID_HASH_RATE_PARAMS, e);
}
final String id = requestContext.getRequiredParameter(1, String.class);
final String id;
try {
id = requestContext.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid sealer ID parameter (index 1)", RpcErrorType.INVALID_SEALER_ID_PARAMS, e);
}
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),
miningCoordinator.submitHashRate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
throw new InvalidJsonRpcParameters(
"Invalid mix hash parameter (index 2)", RpcErrorType.INVALID_MIX_HASH_PARAMS, e);
}
Bytes powHash = Bytes.fromHexString(requestContext.getRequiredParameter(1, String.class));
Bytes powHash;
try {
powHash = Bytes.fromHexString(requestContext.getRequiredParameter(1, String.class));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid PoW hash parameter (index 1)", RpcErrorType.INVALID_POW_HASH_PARAMS, e);
}
final PoWSolution solution = new PoWSolution(nonce, mixHash, null, powHash);
final boolean result = miner.submitWork(solution);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;

import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -55,7 +57,18 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)

LOG.atTrace()
.setMessage("received remote capabilities: {}")
.addArgument(() -> requestContext.getRequiredParameter(0, String[].class))
.addArgument(
() -> {
try {
return requestContext.getRequiredParameter(0, String[].class);
} catch (
Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid remote capabilities parameters (index 0)",
RpcErrorType.INVALID_REMOTE_CAPABILITIES_PARAMS,
e);
}
})
.log();

final List<String> localCapabilities =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}
final String filterId;
try {
filterId = requestContext.getRequiredParameter(1, String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = request.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}
final String filterId;
try {
filterId = request.getRequiredParameter(1, String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,21 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = request.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}
final String filterId;
try {
filterId = request.getRequiredParameter(1, String.class);
} catch (Exception e) {
throw new InvalidJsonRpcParameters(
"Invalid filter ID paramter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
"Invalid filter ID parameter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

if (privacyController instanceof MultiTenancyPrivacyController) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
protected Object resultByBlockNumber(
final JsonRpcRequestContext request, final long blockNumber) {
final JsonCallParameter callParams = validateAndGetCallParams(request);
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = request.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}

final String privacyUserId = privacyIdProvider.getPrivacyUserId(request.getUser());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
@Override
protected Object resultByBlockNumber(
final JsonRpcRequestContext requestContext, final long blockNumber) {
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}
final String privacyUserId = privacyIdProvider.getPrivacyUserId(requestContext.getUser());
if (LOG.isTraceEnabled()) {
LOG.trace("Executing {}", getName());
Expand All @@ -97,7 +105,7 @@ protected Object resultByBlockNumber(
}
} catch (final Exception e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS);
}

if (privacyGroup.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;

Expand Down Expand Up @@ -50,7 +52,15 @@ public String getName() {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
LOG.trace("Executing {}", RpcMethod.PRIV_DELETE_PRIVACY_GROUP.getMethodName());

final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) {
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}

final String response;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
@Override
protected String resultByBlockNumber(
final JsonRpcRequestContext request, final long blockNumber) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = request.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}
final Address address;
try {
address = request.getRequiredParameter(1, Address.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,20 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final String privateFrom = requestContext.getRequiredParameter(1, String.class);
final String[] privateFor = requestContext.getRequiredParameter(2, String[].class);
final String privateFrom;
try {
privateFrom = requestContext.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid private from parameter (index 1)", RpcErrorType.INVALID_PRIVATE_FROM_PARAMS, e);
}
final String[] privateFor;
try {
privateFor = requestContext.getRequiredParameter(2, String[].class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid private for parameter (index 2)", RpcErrorType.INVALID_PRIVATE_FOR_PARAMS, e);
}

final String privacyUserId = privacyIdProvider.getPrivacyUserId(requestContext.getUser());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
final String privacyGroupId;
try {
privacyGroupId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) {
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}
final FilterParameter filter;
try {
filter = requestContext.getRequiredParameter(1, FilterParameter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final String privacyGroupId = requestContext.getRequiredParameter(1, String.class);
final String privacyGroupId;
try {
privacyGroupId = requestContext.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 1)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}

try {
final long nonce =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String privacyGroupId;
try { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
privacyGroupId = request.getRequiredParameter(0, String.class);
} catch (Exception e) {
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
e);
}
final FilterParameter filter;
try {
filter = request.getRequiredParameter(1, FilterParameter.class);
Expand Down
Loading

0 comments on commit 8523ed0

Please sign in to comment.