{"record":{"id":"9c598ab889d4d05a","repo":"apache/iceberg","slug":"failed-to-create-new-data-writer","errorCode":null,"errorMessage":"Failed to create new data writer","messagePattern":"Failed to create new data writer","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"data/src/main/java/org/apache/iceberg/data/RegistryBasedFileWriterFactory.java","lineNumber":123,"sourceCode":"        table != null ? MetricsConfig.forTable(table) : MetricsConfig.getDefault();\n\n    try {\n      FileWriterBuilder<DataWriter<T>, S> builder =\n          FormatModelRegistry.dataWriteBuilder(dataFileFormat, inputType, file);\n      return builder\n          .schema(dataSchema)\n          .engineSchema(inputSchema())\n          .setAll(properties)\n          .setAll(writerProperties)\n          .metricsConfig(metricsConfig)\n          .spec(spec)\n          .partition(partition)\n          .keyMetadata(keyMetadata)\n          .sortOrder(dataSortOrder)\n          .overwrite()\n          .build();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to create new data writer\", e);\n    }\n  }\n\n  @Override\n  public EqualityDeleteWriter<T> newEqualityDeleteWriter(\n      EncryptedOutputFile file, PartitionSpec spec, StructLike partition) {\n    Preconditions.checkArgument(equalityDeleteRowSchema != null, \"Invalid delete schema: null\");\n\n    EncryptionKeyMetadata keyMetadata = file.keyMetadata();\n    Map<String, String> properties = table != null ? table.properties() : ImmutableMap.of();\n    MetricsConfig metricsConfig =\n        table != null ? MetricsConfig.forTable(table) : MetricsConfig.getDefault();\n\n    try {\n      FileWriterBuilder<EqualityDeleteWriter<T>, S> builder =\n          FormatModelRegistry.equalityDeleteWriteBuilder(deleteFileFormat, inputType, file);\n      return builder\n          .setAll(properties)","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/data/src/main/java/org/apache/iceberg/data/RegistryBasedFileWriterFactory.java#L105-L141","documentation":"RegistryBasedFileWriterFactory.newDataWriter builds a DataWriter via a writer registry; an IOException from opening/creating the output data file is wrapped in UncheckedIOException with this message. It means the factory could not produce a writer for the data file (open failure, unknown format, registry misconfiguration).","triggerScenarios":"Calling newDataWriter(file, spec, partition, keyMetadata) where opening the EncryptedOutputFile fails (bad path/bucket, credentials, encryption key error) or no writer is registered for the requested file format.","commonSituations":"Misconfigured write.output format or custom writer registry missing mappings; storage credentials expired; output location not writable; encryption keys misconfigured (encryption.key-id) without KMS access.","solutions":["Inspect the chained IOException cause for the actual open failure (permissions, missing bucket, auth).","Verify the writer registry contains a factory for the table's file format (parquet/avro/orc).","Check output file location and FileIO credentials/permissions.","Fix encryption/keys config if encrypted output files are used."],"exampleFix":"// before: registry lacks an avro writer\n// after: register the writer before use\nfactoryRegistry.addFactory(Avro.DataWriter.class, new AvroDataWriterFactory());","handlingStrategy":"try-catch","validationCode":"// pre-check output writability before creating writers\ntry (OutputStream ignored = io.newOutputFile(location).create()) { }\n","typeGuard":null,"tryCatchPattern":"try {\n  DataWriter<T> writer = factory.newDataWriter(file, spec, partition, keyMetadata);\n} catch (UncheckedIOException e) {\n  log.error(\"Data writer creation failed\", e.getCause());\n  throw e;\n}","preventionTips":["Register writer factories for every file format your tables use before writing.","Validate output location permissions and credentials in job setup.","Test encryption configuration (key ids, KMS access) before production writes."],"tags":["io","writer","factory","unchecked-ioexception","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"}