{"record":{"id":"948222dd6ff1d984","repo":"apache/flink","slug":"program-cannot-be-compiled-this-is-a-bug-please","errorCode":null,"errorMessage":"Program cannot be compiled. This is a bug. Please file an issue.","messagePattern":"Program cannot be compiled\\. This is a bug\\. Please file an issue\\.","errorType":"exception","errorClass":"InvalidProgramException","httpStatus":null,"severity":"critical","filePath":"flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbCodegenUtils.java","lineNumber":262,"sourceCode":"        appender.appendLine(flinkElementVar + \" = \" + flinkContainerElementCode);\n        PbCodegenSerializer codegenSer =\n                PbCodegenSerializeFactory.getPbCodegenSer(\n                        elementPbFd, elementDataType, pbFormatContext);\n        String code = codegenSer.codegen(resultPbVar, flinkElementVar, appender.currentIndent());\n        appender.appendSegment(code);\n        appender.end(\"}\");\n        return appender.code();\n    }\n\n    public static Class compileClass(ClassLoader classloader, String className, String code)\n            throws ClassNotFoundException {\n        SimpleCompiler simpleCompiler = new SimpleCompiler();\n        simpleCompiler.setParentClassLoader(classloader);\n        try {\n            simpleCompiler.cook(code);\n        } catch (Throwable t) {\n            LOG.error(\"Protobuf codegen compile error: \\n\" + code);\n            throw new InvalidProgramException(\n                    \"Program cannot be compiled. This is a bug. Please file an issue.\", t);\n        }\n        return simpleCompiler.getClassLoader().loadClass(className);\n    }\n\n    public static boolean needToSplit(int noSplitCodeSize) {\n        return noSplitCodeSize >= PbConstant.CODEGEN_SPLIT_THRESHOLD;\n    }\n}\n","sourceCodeStart":244,"sourceCodeEnd":272,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbCodegenUtils.java#L244-L272","documentation":"flink-protobuf generates Java source at runtime and compiles it with Janino (SimpleCompiler). If cooking fails — syntax errors or constructs Janino cannot compile in the generated code — the full source is logged and InvalidProgramException('Program cannot be compiled. This is a bug. Please file an issue.') is thrown. By design this always indicates a bug in flink-protobuf's code generator, not user data.","triggerScenarios":"Very large or deeply nested protobuf schemas generating code that exceeds Janino limits or contains unsupported syntax; schema shapes (e.g. specific keyword-colliding identifiers) that produce invalid Java; known codegen bugs in specific flink-protobuf versions.","commonSituations":"Wide enterprise .proto files (hundreds of fields, deep nesting) hitting Janino compiler limits; identifiers in proto that collide with Java keywords; upgrading protobuf schema hits an untested codegen path.","solutions":["Grab the generated source from the LOG.error output ('Protobuf codegen compile error') — it pinpoints the failing construct.","Upgrade flink-protobuf to the latest patch release; many codegen compile bugs are fixed there.","Work around by splitting very large messages into smaller ones or reducing nesting depth.","Rename proto identifiers that collide with Java keywords.","File a Flink JIRA (flink-formats / Protobuf) with the .proto and the logged generated code."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Pre-check size to anticipate Janino limits:\nif (PbCodegenUtils.needToSplit(noSplitCodeSize)) {\n    // ensure you are on a flink-protobuf version where split codegen compiles\n}","typeGuard":null,"tryCatchPattern":"try {\n    clazz = PbCodegenUtils.compileClass(cl, className, code);\n} catch (InvalidProgramException e) {\n    // capture LOG output 'Protobuf codegen compile error' for the bug report;\n    // mitigation: shrink/split the proto schema, then retry\n    throw e;\n}","preventionTips":["Keep proto messages reasonably small and shallow; split god-messages.","Stay on the latest flink-protobuf patch version.","Include the generated-source LOG line in any bug report — it is the key diagnostic."],"tags":["protobuf","codegen","janino","compile-error","bug"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}