{"record":{"id":"22eb161f50a728da","repo":"apache/hadoop","slug":"block-pool-id-required-to-get-aliasmap-reader","errorCode":null,"errorMessage":"Block pool id required to get aliasmap reader","messagePattern":"Block pool id required to get aliasmap reader","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/InMemoryLevelDBAliasMapClient.java","lineNumber":158,"sourceCode":"    @Override\n    public void store(FileRegion fileRegion) throws IOException {\n      aliasMap.write(fileRegion.getBlock(),\n          fileRegion.getProvidedStorageLocation());\n    }\n\n    @Override\n    public void close() throws IOException {\n    }\n  }\n\n  InMemoryLevelDBAliasMapClient() {\n    aliasMaps = new ArrayList<>();\n  }\n\n  private InMemoryAliasMapProtocol getAliasMap(String blockPoolID)\n      throws IOException {\n    if (blockPoolID == null) {\n      throw new IOException(\"Block pool id required to get aliasmap reader\");\n    }\n    // if a block pool id has been supplied, and doesn't match the associated\n    // block pool ids, return null.\n    for (InMemoryAliasMapProtocol aliasMap : aliasMaps) {\n      try {\n        String aliasMapBlockPoolId = aliasMap.getBlockPoolId();\n        if (aliasMapBlockPoolId != null &&\n            aliasMapBlockPoolId.equals(blockPoolID)) {\n          return aliasMap;\n        }\n      } catch (IOException e) {\n        LOG.error(\"Exception in retrieving block pool id {}\", e);\n      }\n    }\n    throw new IOException(\n        \"Unable to retrieve InMemoryAliasMap for block pool id \" + blockPoolID);\n  }\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/InMemoryLevelDBAliasMapClient.java#L140-L176","documentation":"InMemoryLevelDBAliasMapClient.getAliasMap routes each request to the remote LevelDB alias map matching a block pool id. There is no default route: a null blockPoolID fails immediately with this IOException rather than ambiguously querying some cluster.","triggerScenarios":"Calling getReader/getWriter on InMemoryLevelDBAliasMapClient with a null blockPoolID — typically custom integration code or tests that skip the argument, since the DatanodeFileSystem/provided-storage path always threads the bpid from the DN registration.","commonSituations":"Unit tests invoking the alias map client directly; glue code that wires a provided-storage DN but forgets to propagate blockPoolID from DatanodeRegistration.getBlockPoolID().","solutions":["Pass the real block pool id, e.g. from datanodeRegistration.getBlockPoolID() or the BP directory name under the DN's data dir","Fix the caller to thread the bpid parameter through instead of null","Add a null-check assertion early in your wiring so the failure names your call site, not library internals"],"exampleFix":"// before\nReader<FileRegion> r = aliasMapClient.getReader(null, null);\n\n// after\nString bpid = datanodeRegistration.getBlockPoolID();\nReader<FileRegion> r = aliasMapClient.getReader(null, bpid);","handlingStrategy":"validation","validationCode":"if (blockPoolID == null || blockPoolID.isEmpty()) {\n  throw new IllegalArgumentException(\n      \"blockPoolID is required (get it from datanodeRegistration.getBlockPoolID())\");\n}\nReader<FileRegion> r = aliasMapClient.getReader(opts, blockPoolID);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source the block pool id from the DN registration, never hardcode or pass null","Fail fast with your own precondition checks before calling library internals"],"tags":["provided-storage","aliasmap","block-pool","null-argument","inmemory-leveldb"],"backgroundTag":"missing-required-parameter","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}