{"record":{"id":"734a19d6ee16db7d","repo":"apache/iceberg","slug":"unknown-file-content","errorCode":null,"errorMessage":"Unknown file content: ","messagePattern":"Unknown file content: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/avro/AvroFormatModel.java","lineNumber":187,"sourceCode":"          internal.createWriterFunc(\n              avroSchema -> writerFunction.write(schema, avroSchema, engineSchema));\n          break;\n        case POSITION_DELETES:\n          Preconditions.checkState(\n              schema == null,\n              \"Invalid schema: %s. Position deletes with schema are not supported by the API.\",\n              schema);\n          Preconditions.checkState(\n              engineSchema == null,\n              \"Invalid engineSchema: %s. Position deletes with schema are not supported by the API.\",\n              engineSchema);\n\n          internal.createContextFunc(Avro.WriteBuilder.Context::deleteContext);\n          internal.createWriterFunc(unused -> new Avro.PositionDatumWriter());\n          internal.schema(DeleteSchemaUtil.pathPosSchema());\n          break;\n        default:\n          throw new IllegalArgumentException(\"Unknown file content: \" + content);\n      }\n\n      return internal.build();\n    }\n  }\n\n  private static class ReadBuilderWrapper<D, S> implements ReadBuilder<D, S> {\n    private final Avro.ReadBuilder internal;\n    private final ReaderFunction<DatumReader<D>, S, Schema> readerFunction;\n    private S engineSchema;\n    private Map<Integer, ?> idToConstant = ImmutableMap.of();\n\n    private ReadBuilderWrapper(\n        InputFile inputFile, ReaderFunction<DatumReader<D>, S, Schema> readerFunction) {\n      this.internal = Avro.read(inputFile);\n      this.readerFunction = readerFunction;\n    }\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/avro/AvroFormatModel.java#L169-L205","documentation":"AvroFormatModel's ModelWriteBuilder.build() switches on the configured FileContent (DATA, POSITION_DELETES, EQUALITY_DELETES). If the content was set to an unrecognized value, build throws IllegalArgumentException('Unknown file content: ' + content). This is an internal invariant guard over the builder's content field.","triggerScenarios":"Setting a FileContent value on the Avro write builder that the switch does not handle — typically by passing a custom/incorrect enum value via withContent(), or a newly added FileContent type not yet supported by the Avro writer path.","commonSituations":"Generic write code passing content types supported only by other formats; version skew where a new Iceberg FileContent (e.g. equality deletes or future types) reaches an older Avro writer; misuse of the internal builder API with null or bogus content.","solutions":["Only set FileContent values supported by the Avro writer: DATA, POSITION_DELETES, or the supported delete types","Use the format-appropriate constant from FileContent instead of raw values","Check that the generic write path does not forward content types unsupported by Avro","Upgrade Iceberg if a newer content type must be written with Avro"],"exampleFix":"// before\nbuilder.withContent((FileContent) null); // leads to 'Unknown file content: null'\n\n// after\nbuilder.withContent(FileContent.DATA); // or FileContent.POSITION_DELETES","handlingStrategy":"validation","validationCode":"if (content != FileContent.DATA && content != FileContent.POSITION_DELETES) { throw new IllegalArgumentException(\"Content not supported by Avro writer: \" + content); }","typeGuard":"boolean avroSupported(FileContent c) { return c == FileContent.DATA || c == FileContent.POSITION_DELETES; }","tryCatchPattern":"try { return builder.build(); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unknown file content\")) { /* correct the content or switch format */ } throw e; }","preventionTips":["Only pass FileContent enum constants supported by the Avro path","Keep generic write code aligned with per-format capability","Upgrade Iceberg when new FileContent types must be written"],"tags":["avro","file-content","builder","illegal-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}