{"record":{"id":"0900ab3a959f10d5","repo":"apache/flink","slug":"protocol-buffer-class-or-descriptor-not-specified","errorCode":null,"errorMessage":"Protocol buffer class or descriptor not specified. Please use method ProtoParquetOutputFormat.setProtobufClass(...) or other similar method.","messagePattern":"Protocol buffer class or descriptor not specified\\. Please use method ProtoParquetOutputFormat\\.setProtobufClass\\(\\.\\.\\.\\) or other similar method\\.","errorType":"validation","errorClass":"BadConfigurationException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/protobuf/PatchedProtoWriteSupport.java","lineNumber":197,"sourceCode":"    @Override\n    public WriteContext init(ParquetConfiguration configuration) {\n\n        Map<String, String> extraMetaData = new HashMap<>();\n\n        // if no protobuf descriptor was given in constructor, load descriptor from configuration\n        // (set with\n        // setProtobufClass)\n        if (descriptor == null) {\n            if (protoMessage == null) {\n                Class<? extends Message> pbClass =\n                        configuration.getClass(PB_CLASS_WRITE, null, Message.class);\n                if (pbClass != null) {\n                    protoMessage = pbClass;\n                } else {\n                    String msg = \"Protocol buffer class or descriptor not specified.\";\n                    String hint =\n                            \" Please use method ProtoParquetOutputFormat.setProtobufClass(...) or other similar method.\";\n                    throw new BadConfigurationException(msg + hint);\n                }\n            }\n            descriptor = Protobufs.getMessageDescriptor(protoMessage);\n            extraMetaData.put(ProtoReadSupport.PB_CLASS, protoMessage.getName());\n        }\n\n        unwrapProtoWrappers =\n                configuration.getBoolean(PB_UNWRAP_PROTO_WRAPPERS, unwrapProtoWrappers);\n        writeSpecsCompliant =\n                configuration.getBoolean(PB_SPECS_COMPLIANT_WRITE, writeSpecsCompliant);\n        MessageType rootSchema = new PatchedProtoSchemaConverter(configuration).convert(descriptor);\n        validatedMapping(descriptor, rootSchema);\n\n        this.messageWriter = new MessageWriter(descriptor, rootSchema);\n\n        extraMetaData.put(ProtoReadSupport.PB_DESCRIPTOR, descriptor.toProto().toString());\n        extraMetaData.put(PB_SPECS_COMPLIANT_WRITE, String.valueOf(writeSpecsCompliant));\n        extraMetaData.put(PB_UNWRAP_PROTO_WRAPPERS, String.valueOf(unwrapProtoWrappers));","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/protobuf/PatchedProtoWriteSupport.java#L179-L215","documentation":"PatchedProtoWriteSupport.init throws BadConfigurationException when no protobuf descriptor and no protobuf message class was configured. The writer needs either a Message class or descriptor to derive the parquet schema before writing.","triggerScenarios":"Creating ProtoParquetOutputFormat / the patched write support without calling setProtobufClass(...) or setProtobufDescriptor(...) (or the equivalent PB_CLASS_WRITE hadoop configuration key) before use.","commonSituations":"Copy-pasting output format setup and forgetting the class/descriptor line; constructing the write support directly in tests; relying on configuration that got lost when copying a Hadoop Configuration.","solutions":["Call ProtoParquetOutputFormat.setProtobufClass(MyMessage.class) (or setProtobufDescriptor(...)) before writing","Verify the PB_CLASS_WRITE key survives any Configuration cloning/copying in your setup code","Fail fast at job construction: assert the class/descriptor is set before submitting the job"],"exampleFix":"// before\nProtoParquetOutputFormat<MyMessage> out = new ProtoParquetOutputFormat<>(outPath);\n\n// after\nProtoParquetOutputFormat<MyMessage> out = new ProtoParquetOutputFormat<>(outPath);\nout.setProtobufClass(MyMessage.class);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(protoClassOrDescriptor, \"setProtobufClass/setProtobufDescriptor before use\"); // or assert conf.get(PB_CLASS_WRITE) != null","typeGuard":null,"tryCatchPattern":"try { support.init(conf); } catch (BadConfigurationException e) { // fail the job setup with a clear operator-level message; do not retry }","preventionTips":["Set the protobuf class/descriptor at format construction time, not lazily","Add a startup assertion that PB_CLASS_WRITE is present in the effective Configuration","Watch for Configuration.copy() dropping custom keys"],"tags":["parquet","protobuf","configuration","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}