private void accountAndContainerSanityCheck(RestRequest restRequest) throws RestServiceException {
    NamedBlobPath namedBlobPath = null;
    if (getRequestPath(restRequest).matchesOperation(Operations.NAMED_BLOB)) {
      namedBlobPath = NamedBlobPath.parse(getRequestPath(restRequest), restRequest.getArgs());
    }
    if (Account.UNKNOWN_ACCOUNT_NAME.equals(getHeader(restRequest.getArgs(), Headers.TARGET_ACCOUNT_NAME, false))
        || Account.UNKNOWN_ACCOUNT_NAME.equals(getHeader(restRequest.getArgs(), Headers.SERVICE_ID, false)) || (
        namedBlobPath != null && Account.UNKNOWN_ACCOUNT_NAME.equals(namedBlobPath.getAccountName()))) {
      throw new RestServiceException("Invalid account for putting blob", RestServiceErrorCode.InvalidAccount);
    }
    String targetContainerName = getHeader(restRequest.getArgs(), Headers.TARGET_CONTAINER_NAME, false);
    if (Container.UNKNOWN_CONTAINER_NAME.equals(targetContainerName) || (namedBlobPath != null
        && Container.UNKNOWN_CONTAINER_NAME.equals(namedBlobPath.getContainerName()))) {
      throw new RestServiceException("Invalid container for putting blob", RestServiceErrorCode.InvalidContainer);
    }
    //when delete the dataset, we need to delete the dataset version as well, so the InternalKeys.TARGET_ACCOUNT_KEY
    //and InternalKeys.TARGET_CONTAINER_KEY already existed. We need to bypass this check.
    if (!(RequestPath.matchesOperation(restRequest.getUri(), ACCOUNTS_CONTAINERS_DATASETS)
        && restRequest.getRestMethod() == RestMethod.DELETE)) {
      List<String> prohibitedHeaders =
          Arrays.asList(InternalKeys.TARGET_ACCOUNT_KEY, InternalKeys.TARGET_CONTAINER_KEY);
      for (String prohibitedHeader : prohibitedHeaders) {
        if (restRequest.getArgs().get(prohibitedHeader) != null) {
          throw new RestServiceException("Unexpected header " + prohibitedHeader + " in request",
              RestServiceErrorCode.BadRequest);
        }
      }
    }
  }
Sanity check for {@link RestRequest}. This check ensures that the specified service id, account and container name,
if they exist, should not be the same as the not-allowed values. It also makes sure certain headers must not be present.
@param restRequest The {@link RestRequest} to check.
@throws RestServiceException if the specified service id, account or container name is set as system reserved value.
ambry-frontend/src/main/java/com/github/ambry/frontend/AccountAndContainerInjector.java