apache/hadoop · error · IOException

Provided block and location cannot be null

Error message

Provided block and location cannot be null

What it means

Same InMemoryAliasMap translator as read(): write() stores a Block -> ProvidedStorageLocation mapping on the alias-map server. Both arguments are @Nonnull because the WriteRequestProto KeyValueProto needs a full key and value; a null on either side cannot be serialized and fails fast with IOException.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/InMemoryAliasMapProtocolClientSideTranslatorPB.java:188

            .setKey(PBHelperClient.convert(block))
            .build();
    ReadResponseProto response = ipc(() -> rpcProxy.read(null, request));

    ProvidedStorageLocationProto providedStorageLocation =
        response.getValue();
    if (providedStorageLocation.isInitialized()) {
      return Optional.of(PBHelperClient.convert(providedStorageLocation));
    }
    return Optional.empty();

  }

  @Override
  public void write(@Nonnull Block block,
      @Nonnull ProvidedStorageLocation providedStorageLocation)
      throws IOException {
    if (block == null || providedStorageLocation == null) {
      throw new IOException("Provided block and location cannot be null");
    }
    WriteRequestProto request =
        WriteRequestProto
            .newBuilder()
            .setKeyValuePair(KeyValueProto.newBuilder()
                .setKey(PBHelperClient.convert(block))
                .setValue(PBHelperClient.convert(providedStorageLocation))
                .build())
            .build();

    ipc(() -> rpcProxy.write(null, request));
  }

  @Override
  public String getBlockPoolId() throws IOException {
    BlockPoolResponseProto response = ipc(() -> rpcProxy.getBlockPoolId(null,
        BlockPoolRequestProto.newBuilder().build()));
    return response.getBlockPoolId();

View on GitHub (pinned to 2add963021)

Solutions

  1. Construct both the Block and the ProvidedStorageLocation (uri, offset, length, version) fully before calling write().
  2. Guard at the data source: skip or reject file-region records whose block or location field is missing instead of passing null.
  3. Add validation/unit tests on the ingestion path that produces the mappings.

Example fix

// before
aliasMap.write(block, null); // location not yet resolved

// after
if (providedStorageLocation == null || block == null) {
  throw new IllegalArgumentException("block and location are both required");
}
aliasMap.write(block, providedStorageLocation);
Defensive patterns

Strategy: validation

Validate before calling

if (block == null || providedStorageLocation == null) {
  throw new IllegalArgumentException(
      "block and ProvidedStorageLocation are both required");
}
aliasMap.write(block, providedStorageLocation);

Type guard

static boolean isWritableMapping(Block b, ProvidedStorageLocation l) {
  return b != null && l != null && l.getPath() != null
      && l.getLength() >= 0 && l.getOffset() >= 0;
}

Try / catch

try {
  aliasMap.write(block, providedStorageLocation);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().contains("cannot be null")) {
    throw new IllegalStateException("incomplete mapping passed to alias-map write", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling write(block, providedStorageLocation) where block is null or providedStorageLocation is null — e.g. a migration/ingestion tool writing mappings before it has resolved the location, or a partially-initialized ProvidedStorageLocation.

Common situations: Provided Storage ingestion tools, custom alias-map loaders, unit tests of the alias map protocol; caller-side data-flow bug, not cluster config.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/18139d64a61230f2. Report an issue: GitHub.