{"record":{"id":"b4a7baa6c362a122","repo":"apache/hadoop","slug":"attempt-to-create-an-encryption-zone-for-a-non-emp","errorCode":null,"errorMessage":"Attempt to create an encryption zone for a non-empty directory.","messagePattern":"Attempt to create an encryption zone for a non-empty directory\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java","lineNumber":557,"sourceCode":"\n    // Check if src is a valid path for new EZ creation\n    if (srcIIP.getLastINode() == null) {\n      throw new FileNotFoundException(\"cannot find \" + srcIIP.getPath());\n    }\n\n    INode srcINode = srcIIP.getLastINode();\n    if (!srcINode.isDirectory()) {\n      throw new IOException(\"Attempt to create an encryption zone for a file.\");\n    }\n\n    if (hasCreatedEncryptionZone() && encryptionZones.\n        get(srcINode.getId()) != null) {\n      throw new IOException(\n          \"Directory \" + srcIIP.getPath() + \" is already an encryption zone.\");\n    }\n\n    if (dir.isNonEmptyDirectory(srcIIP)) {\n      throw new IOException(\n          \"Attempt to create an encryption zone for a non-empty directory.\");\n    }\n    final HdfsProtos.ZoneEncryptionInfoProto proto =\n        PBHelperClient.convert(suite, version, keyName);\n    final XAttr ezXAttr = XAttrHelper\n        .buildXAttr(CRYPTO_XATTR_ENCRYPTION_ZONE, proto.toByteArray());\n\n    final List<XAttr> xattrs = Lists.newArrayListWithCapacity(1);\n    xattrs.add(ezXAttr);\n    // updating the xattr will call addEncryptionZone,\n    // done this way to handle edit log loading\n    FSDirXAttrOp.unprotectedSetXAttrs(dir, srcIIP, xattrs,\n                                      EnumSet.of(XAttrSetFlag.CREATE));\n    return ezXAttr;\n  }\n\n  /**\n   * Cursor-based listing of encryption zones.","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java#L539-L575","documentation":"Error \"Attempt to create an encryption zone for a non-empty directory.\" thrown in apache/hadoop.","triggerScenarios":"createEncryptionZone on a directory that is not empty; zones must be created on empty directories.","commonSituations":"See trigger scenarios.","solutions":["Create the encryption zone on an empty directory; move or delete existing files first, or create a new empty directory for the zone."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}