{"record":{"id":"10665d1bafa38f31","repo":"apache/hadoop","slug":"unknown-openfiletype","errorCode":null,"errorMessage":"Unknown OpenFileType: {}","messagePattern":"Unknown OpenFileType: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java","lineNumber":2091,"sourceCode":"      EnumSet<OpenFilesType> openFilesTypes, String path) throws IOException {\n    INode.checkAbsolutePath(path);\n    final String operationName = \"listOpenFiles\";\n    checkSuperuserPrivilege(operationName, path);\n    checkOperation(OperationCategory.READ);\n    BatchedListEntries<OpenFileEntry> batchedListEntries;\n    String normalizedPath = new Path(path).toString(); // normalize path.\n    try {\n      readLock(RwLockMode.FS);\n      try {\n        checkOperation(OperationCategory.READ);\n        if (openFilesTypes.contains(OpenFilesType.ALL_OPEN_FILES)) {\n          batchedListEntries = leaseManager.getUnderConstructionFiles(prevId,\n              normalizedPath);\n        } else {\n          if (openFilesTypes.contains(OpenFilesType.BLOCKING_DECOMMISSION)) {\n            batchedListEntries = getFilesBlockingDecom(prevId, normalizedPath);\n          } else {\n            throw new IllegalArgumentException(\"Unknown OpenFileType: \"\n                + openFilesTypes);\n          }\n        }\n      } finally {\n        readUnlock(RwLockMode.FS, operationName, getLockReportInfoSupplier(null));\n      }\n    } catch (AccessControlException e) {\n      logAuditEvent(false, operationName, null);\n      throw e;\n    }\n    logAuditEvent(true, operationName, null);\n    return batchedListEntries;\n  }\n\n  public BatchedListEntries<OpenFileEntry> getFilesBlockingDecom(long prevId,\n      String path) {\n    assert hasReadLock(RwLockMode.FS);\n    final List<OpenFileEntry> openFileEntries = Lists.newArrayList();","sourceCodeStart":2073,"sourceCodeEnd":2109,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java#L2073-L2109","documentation":"FSNamesystem.listOpenFiles dispatches on the EnumSet of OpenFilesType supplied by the client. The deployed enum has only ALL_OPEN_FILES and BLOCKING_DECOMMISSION; if the set contains neither (empty set or a value unknown to this NameNode), control falls into the final else branch and throws IllegalArgumentException('Unknown OpenFileType: ...').","triggerScenarios":"Calling ClientProtocol.listOpenFiles / DistributedFileSystem.listOpenFiles with an empty OpenFilesType array (e.g. EnumSet.noneOf(OpenFilesType.class)), or a client compiled against a Hadoop version whose OpenFilesType values differ from the NameNode's so the deserialized set matches no branch.","commonSituations":"Custom monitoring tooling that builds the filter set from config and ends up empty; client/server version skew after a rolling upgrade; code that treats a null filter as 'none' instead of defaulting to 'all'.","solutions":["Pass a valid non-empty set: EnumSet.of(OpenFilesType.ALL_OPEN_FILES) or EnumSet.of(OpenFilesType.BLOCKING_DECOMMISSION)","Rebuild the client against the same Hadoop version as the NameNode to remove enum skew","Use `hdfs dfsadmin -listOpenFiles` (optionally -blockingDecommission), which always sends a valid set"],"exampleFix":"// before\nOpenFilesType[] types = typesFromConfig; // may be empty -> IllegalArgumentException\nRemoteIterator<OpenFileEntry> it = dfs.listOpenFiles(types);\n// after\nEnumSet<OpenFilesType> set = (types == null || types.length == 0)\n    ? EnumSet.of(OpenFilesType.ALL_OPEN_FILES)\n    : EnumSet.noneOf(OpenFilesType.class);\nif (types != null) Collections.addAll(set, types);\nRemoteIterator<OpenFileEntry> it = dfs.listOpenFiles(set.toArray(new OpenFilesType[0]));","handlingStrategy":"validation","validationCode":"Set<OpenFilesType> t = (types == null || types.isEmpty())\n    ? EnumSet.of(OpenFilesType.ALL_OPEN_FILES) : EnumSet.copyOf(types);\nboolean valid = t.stream().allMatch(v ->\n    v == OpenFilesType.ALL_OPEN_FILES || v == OpenFilesType.BLOCKING_DECOMMISSION);\nif (!valid) t = EnumSet.of(OpenFilesType.ALL_OPEN_FILES);","typeGuard":"static boolean isOpenFilesQueryValid(Collection<OpenFilesType> c) {\n  if (c == null || c.isEmpty()) return false;\n  for (OpenFilesType v : c) {\n    if (v != OpenFilesType.ALL_OPEN_FILES && v != OpenFilesType.BLOCKING_DECOMMISSION) return false;\n  }\n  return true;\n}","tryCatchPattern":"catch (IllegalArgumentException e) { if (e.getMessage() != null && e.getMessage().contains(\"Unknown OpenFileType\")) { query = EnumSet.of(OpenFilesType.ALL_OPEN_FILES); continue; } throw e; }","preventionTips":["Default empty filter sets to ALL_OPEN_FILES instead of sending them","Pin client and server to the same Hadoop release to avoid enum drift"],"tags":["hdfs","namenode","client-protocol","enum","illegal-argument","open-files"],"backgroundTag":"invalid-enum-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}