{"record":{"id":"002236c84b5503f7","repo":"apache/beam","slug":"configuration-with-s-is-not-compatible-with-a-s-format","errorCode":null,"errorMessage":"configuration with %s is not compatible with a %s format","messagePattern":"configuration with (.+?) is not compatible with a (.+?) format","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/file-schema-transform/src/main/java/org/apache/beam/sdk/io/fileschematransform/FileWriteSchemaTransformProvider.java","lineNumber":174,"sourceCode":"                \"%s is not a supported format. See %s for a list of supported formats.\",\n                configuration.getFormat(),\n                FileWriteSchemaTransformFormatProviders.class.getName()));\n      }\n      // resolves [dereference.of.nullable]\n      Optional<FileWriteSchemaTransformFormatProvider> provider =\n          Optional.ofNullable(providers.get(configuration.getFormat()));\n      checkState(provider.isPresent());\n      return provider.get();\n    }\n\n    /**\n     * Validates a {@link FileWriteSchemaTransformConfiguration} for correctness depending on its\n     * {@link FileWriteSchemaTransformConfiguration#getFormat()}.\n     */\n    static void validateConfiguration(FileWriteSchemaTransformConfiguration configuration) {\n      String format = configuration.getFormat();\n      if (configuration.getCsvConfiguration() != null && !format.equals(CSV)) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"configuration with %s is not compatible with a %s format\",\n                FileWriteSchemaTransformConfiguration.CsvConfiguration.class.getName(), format));\n      }\n      if (configuration.getParquetConfiguration() != null && !format.equals(PARQUET)) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"configuration with %s is not compatible with a %s format\",\n                FileWriteSchemaTransformConfiguration.ParquetConfiguration.class.getName(),\n                format));\n      }\n      if (configuration.getXmlConfiguration() != null && !format.equals(XML)) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"configuration with %s is not compatible with a %s format\",\n                FileWriteSchemaTransformConfiguration.XmlConfiguration.class.getName(), format));\n      }\n      if (format.equals(AVRO) && !Strings.isNullOrEmpty(configuration.getCompression())) {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/file-schema-transform/src/main/java/org/apache/beam/sdk/io/fileschematransform/FileWriteSchemaTransformProvider.java#L156-L192","documentation":"validateConfiguration enforces that a CsvConfiguration is only set when the format is \"csv\". If csvConfiguration is non-null but format is something else, it throws IllegalArgumentException stating the incompatibility. This catches contradictory configuration where sub-configs for one format are supplied with another format.","triggerScenarios":"FileWriteSchemaTransformConfiguration.builder().setFormat(\"parquet\").setCsvConfiguration(CsvConfiguration.builder()...build()) — any non-CSV format combined with a non-null CsvConfiguration.","commonSituations":"Copy-pasting a configuration builder and changing the format but forgetting to remove setCsvConfiguration; building configs dynamically where CSV options are always attached; YAML/JSON config files carrying csv fields reused for parquet output.","solutions":["Remove setCsvConfiguration(...) when the format is not csv","Only attach the sub-configuration matching the chosen format (csv->CsvConfiguration, parquet->ParquetConfiguration, xml->XmlConfiguration)","If format comes from user input, validate format first and conditionally attach sub-configs","Simplify the config template so only the relevant sub-config block is present"],"exampleFix":"// before\nFileWriteSchemaTransformConfiguration.builder()\n    .setFormat(\"parquet\")\n    .setCsvConfiguration(CsvConfiguration.builder().build())\n// after\nFileWriteSchemaTransformConfiguration.builder()\n    .setFormat(\"parquet\")\n    .setParquetConfiguration(ParquetConfiguration.builder().build())","handlingStrategy":"validation","validationCode":"if (config.getCsvConfiguration() != null && !\"csv\".equals(config.getFormat()))\n  throw new IllegalArgumentException(\"csvConfiguration requires format=csv\");","typeGuard":null,"tryCatchPattern":"// Validate before building the configuration\nif (csvOpts != null && !\"csv\".equals(format)) {\n  throw new IllegalArgumentException(\"Drop csvConfiguration when format is \" + format);\n}","preventionTips":["Build configurations with builder methods that pair format+subconfig in one helper","Never reuse a single config object across different format jobs","Add format-conditional logic wherever sub-configs are attached programmatically"],"tags":["java","beam","schema-transform","config-validation"],"backgroundTag":"conflicting-config-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}