{"record":{"id":"31d0a557f0f523ff","repo":"apache/beam","slug":"at-least-a-descriptorpath-or-a-proto-schema-is-required","errorCode":null,"errorMessage":"At least a descriptorPath or a proto Schema is required.","messagePattern":"At least a descriptorPath or a proto Schema is required\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaWriteSchemaTransformProvider.java","lineNumber":227,"sourceCode":"        toBytesFn = getRowToRawBytesFunction(inputSchema.getField(0).getName());\n      } else if (configuration.getFormat().equals(\"JSON\")) {\n        toBytesFn = JsonUtils.getRowToJsonBytesFunction(inputSchema);\n      } else if (configuration.getFormat().equals(\"PROTO\")) {\n        String descriptorPath = configuration.getFileDescriptorPath();\n        String schema = configuration.getSchema();\n        String messageName = configuration.getMessageName();\n        if (messageName == null) {\n          throw new IllegalArgumentException(\"Expecting messageName to be non-null.\");\n        }\n        if (descriptorPath != null && schema != null) {\n          throw new IllegalArgumentException(\n              \"You must include a descriptorPath or a proto Schema but not both.\");\n        } else if (descriptorPath != null) {\n          toBytesFn = ProtoByteUtils.getRowToProtoBytes(descriptorPath, messageName);\n        } else if (schema != null) {\n          toBytesFn = ProtoByteUtils.getRowToProtoBytesFromSchema(schema, messageName);\n        } else {\n          throw new IllegalArgumentException(\n              \"At least a descriptorPath or a proto Schema is required.\");\n        }\n      } else {\n        if (configuration.getProducerConfigUpdates() != null\n            && configuration.getProducerConfigUpdates().containsKey(\"schema.registry.url\")) {\n          toGenericRecordsFn = AvroUtils.getRowToGenericRecordFunction(avroSchema);\n          toBytesFn = null;\n        } else {\n          toBytesFn = AvroUtils.getRowToAvroBytesFunction(inputSchema);\n        }\n      }\n\n      boolean handleErrors = ErrorHandling.hasOutput(configuration.getErrorHandling());\n      final Map<String, String> configOverrides = configuration.getProducerConfigUpdates();\n      Schema errorSchema = ErrorHandling.errorSchema(inputSchema);\n      PCollectionTuple outputTuple;\n      if (toGenericRecordsFn != null) {\n        LOG.info(\"Convert to GenericRecord with schema {}\", avroSchema);","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaWriteSchemaTransformProvider.java#L209-L245","documentation":"Companion guard to the exclusive-or check in KafkaWriteSchemaTransformProvider: when the format is PROTO but neither fileDescriptorPath nor schema is set (only messageName given), expand() throws because it has no way to obtain the proto descriptor needed to serialize rows.","triggerScenarios":"Thrown at sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaWriteSchemaTransformProvider.java:227 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set either fileDescriptorPath (path to a descriptor set file) or an inline schema string in the configuration.","Ensure messageName is supplied along with one of the two descriptor sources."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}