{"record":{"id":"7bffe83db2403a66","repo":"apache/iceberg","slug":"failed-to-create-file-s-7bffe8","errorCode":null,"errorMessage":"Failed to create file: %s","messagePattern":"Failed to create file: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopOutputFile.java","lineNumber":78,"sourceCode":"\n  public static OutputFile fromPath(Path path, FileSystem fs, Configuration conf) {\n    return new HadoopOutputFile(fs, path, conf);\n  }\n\n  private HadoopOutputFile(FileSystem fs, Path path, Configuration conf) {\n    this.fs = fs;\n    this.path = path;\n    this.conf = conf;\n  }\n\n  @Override\n  public PositionOutputStream create() {\n    try {\n      return HadoopStreams.wrap(fs.create(path, false /* createOrOverwrite */));\n    } catch (FileAlreadyExistsException e) {\n      throw new AlreadyExistsException(e, \"Path already exists: %s\", path);\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Failed to create file: %s\", path);\n    }\n  }\n\n  @Override\n  public PositionOutputStream createOrOverwrite() {\n    try {\n      return HadoopStreams.wrap(fs.create(path, true /* createOrOverwrite */));\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Failed to create file: %s\", path);\n    }\n  }\n\n  public Path getPath() {\n    return path;\n  }\n\n  public Configuration getConf() {\n    return conf;","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopOutputFile.java#L60-L96","documentation":"HadoopOutputFile.create() wraps any non-already-exists IOException from fs.create into a RuntimeIOException with 'Failed to create file'. This covers everything except the duplicate-path case handled above.","triggerScenarios":"Calling create() when fs.create throws IOException for reasons other than file-exists: permission denied, parent directory missing, NameNode unreachable, quota exceeded, S3 access denied/throttling.","commonSituations":"Missing HDFS directory (no mkdirs beforehand); write permissions missing for the job user; HDFS quota/space exceeded; bad S3 credentials or missing bucket.","solutions":["Ensure parent directories exist (fs.mkdirs) or write to a location that does","Verify write permissions/credentials for the target path","Check quotas and free space on the filesystem","Retry transient network/RPC failures with backoff"],"exampleFix":"// before\nPositionOutputStream s = io.newOutputFile(\"hdfs://nn/data/part-0.parquet\").create();\n// after\nFileSystem fs = FileSystem.get(conf);\nPath p = new Path(\"hdfs://nn/data/part-0.parquet\");\nfs.mkdirs(p.getParent());\nPositionOutputStream s = io.newOutputFile(p.toString()).create();","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["hadoop","io","file-write"],"backgroundTag":"file-write-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}