{"record":{"id":"3095ad1e290c577a","repo":"quarkusio/quarkus","slug":"failed-to-compile-avro-protocole-file-filepath","errorCode":null,"errorMessage":"Failed to compile avro protocole file: ${filePath} to Java","messagePattern":"Failed to compile avro protocole file: (.+?) to Java","errorType":"exception","errorClass":"CodeGenException","httpStatus":null,"severity":"error","filePath":"extensions/avro/deployment/src/main/java/io/quarkus/avro/deployment/AvroProtocolCodeGenProvider.java","lineNumber":51,"sourceCode":"    void compileSingleFile(Path filePath,\n            Path outputDirectory,\n            AvroOptions options) throws CodeGenException {\n        try {\n            final Protocol protocol = Protocol.parse(filePath.toFile());\n            final SpecificCompiler compiler = new SpecificCompiler(protocol);\n            compiler.setTemplateDir(templateDirectory);\n            compiler.setStringType(options.stringType);\n            compiler.setFieldVisibility(SpecificCompiler.FieldVisibility.PRIVATE);\n            compiler.setCreateOptionalGetters(options.createOptionalGetters);\n            compiler.setGettersReturnOptional(options.gettersReturnOptional);\n            compiler.setOptionalGettersForNullableFieldsOnly(options.optionalGettersForNullableFieldsOnly);\n            compiler.setCreateSetters(options.createSetters);\n            compiler.setEnableDecimalLogicalType(options.enableDecimalLogicalType);\n\n            compiler.setOutputCharacterEncoding(\"UTF-8\");\n            compiler.compileToDestination(filePath.toFile(), outputDirectory.toFile());\n        } catch (IOException e) {\n            throw new CodeGenException(\"Failed to compile avro protocole file: \" + filePath.toString() + \" to Java\", e);\n        }\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":55,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/avro/deployment/src/main/java/io/quarkus/avro/deployment/AvroProtocolCodeGenProvider.java#L33-L55","documentation":"Same as the IDL failure but for Avro protocol (.avpr) files: the Quarkus Avro deployment wraps IOException thrown by the Avro protocol compiler when turning a .avpr file into Java classes. The file could not be parsed as a valid Avro protocol or read from disk.","triggerScenarios":"Code-gen phase encounters a .avpr file under src/main/avro that is malformed JSON, not a valid protocol object, or unreadable.","commonSituations":"Hand-edited .avpr with JSON syntax errors; file is actually a schema, not a protocol; truncated/invalid UTF-8 file; wrong file placed in the avro source dir.","solutions":["Inspect the chained cause for the JSON/protocol parse error and fix the .avpr file","Validate the .avpr parses as a valid Avro protocol JSON (e.g. with avro-tools or a JSON linter)","Ensure the file is a protocol (has 'protocol', 'types', 'messages') not a plain schema","Check file permissions/encoding"],"exampleFix":"// before (invalid: missing protocol wrapper)\n{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"}]}\n// after\n{\"protocol\":\"MyProto\",\"types\":[{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"}]}],\"messages\":{}}","handlingStrategy":"validation","validationCode":"// validate .avpr is parseable JSON protocol before build\nString json = Files.readString(Path.of(\"src/main/avro/My.avpr\"));\nif (!json.trim().startsWith(\"{\") || !json.contains(\"\\\"protocol\\\"\")) {\n    throw new IllegalArgumentException(\"Not a valid Avro protocol file\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    project.build();\n} catch (CodeGenException e) {\n    log.error(\"Avro protocol compile failed: \" + e.getCause(), e);\n}","preventionTips":["Lint .avpr files as JSON in CI","Ensure .avpr files are protocols, not schemas","Validate with avro-tools protoc compile locally","Use UTF-8 without BOM for protocol files"],"tags":["avro","codegen","protocol","quarkus"],"backgroundTag":"avro-idl-compilation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}