{"record":{"id":"93417bbe46e2d93e","repo":"apache/hadoop","slug":"invalid-options-opts-getclass-93417b","errorCode":null,"errorMessage":"Invalid options \" + opts.getClass()","messagePattern":"Invalid options \" \\+ opts\\.getClass\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java","lineNumber":93,"sourceCode":"  public void setConf(Configuration conf) {\n    readerOpts.setConf(conf);\n    writerOpts.setConf(conf);\n    this.conf = conf;\n  }\n\n  @Override\n  public Configuration getConf() {\n    return conf;\n  }\n\n  @Override\n  public Reader<FileRegion> getReader(Reader.Options opts, String blockPoolID)\n      throws IOException {\n    if (null == opts) {\n      opts = readerOpts;\n    }\n    if (!(opts instanceof ReaderOptions)) {\n      throw new IllegalArgumentException(\"Invalid options \" + opts.getClass());\n    }\n    ReaderOptions o = (ReaderOptions) opts;\n    Configuration readerConf = (null == o.getConf())\n        ? new Configuration()\n            : o.getConf();\n    return createReader(o.file, o.delim, readerConf, blockPoolID);\n  }\n\n  @VisibleForTesting\n  TextReader createReader(Path file, String delim, Configuration cfg,\n      String blockPoolID) throws IOException {\n    FileSystem fs = file.getFileSystem(cfg);\n    if (fs instanceof LocalFileSystem) {\n      fs = ((LocalFileSystem)fs).getRaw();\n    }\n    CompressionCodecFactory factory = new CompressionCodecFactory(cfg);\n    CompressionCodec codec = factory.getCodec(file);\n    String filename = fileNameFromBlockPoolID(blockPoolID);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java#L75-L111","documentation":"TextFileRegionAliasMap.getReader requires its own ReaderOptions (file path, delimiter, codec, conf) to locate and parse the alias text file; any other Reader.Options implementation is rejected with IllegalArgumentException before the file is opened.","triggerScenarios":"Passing options from another alias map implementation (LevelDBOptions, InMemory client options) or a custom Options class to getReader of TextFileRegionAliasMap.","commonSituations":"Generic factory code over BlockAliasMap implementations sharing one Options instance; swapping dfs.provided.aliasmap.class between leveldb and text without updating option construction.","solutions":["Pass null so the map builds ReaderOptions from configuration (dfs.provided.aliasmap.text.path etc.)","Or construct TextFileRegionAliasMap.ReaderOptions and set file/delimiter/codec explicitly","Pair each Options object with its owning implementation"],"exampleFix":"// before\nBlockAliasMap.Reader.Options o = new LevelDBFileRegionAliasMap.LevelDBOptions();\nReader<FileRegion> r = textAliasMap.getReader(o, bpid);\n\n// after\nReader<FileRegion> r = textAliasMap.getReader(null, bpid);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean validReaderOpts(TextFileRegionAliasMap map,\n    BlockAliasMap.Reader.Options o) {\n  return o == null || o instanceof TextFileRegionAliasMap.ReaderOptions;\n}","tryCatchPattern":null,"preventionTips":["Pass null and rely on dfs.provided.aliasmap.text.* configuration","Keep each Options type confined to its implementation"],"tags":["provided-storage","aliasmap","text","options","illegal-argument"],"backgroundTag":"options-type-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}