{"record":{"id":"95370bec5c7f09eb","repo":"apache/beam","slug":"standard-logical-type-s-does-not-have-a-zero-argument","errorCode":null,"errorMessage":"Standard logical type '%s' does not have a zero-argument constructor.","messagePattern":"Standard logical type '(.+?)' does not have a zero-argument constructor\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java","lineNumber":450,"sourceCode":"            } catch (IllegalAccessException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Standard logical type '%s' has an of('%s') method, but it is not accessible.\",\n                      urn, objectName),\n                  e);\n            } catch (InvocationTargetException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Error instantiating logical type '%s' with of('%s') method.\",\n                      urn, objectName),\n                  e);\n            }\n          } else {\n            // Logical type without argument. Construct from constructor without parameter\n            try {\n              return FieldType.logicalType(logicalTypeClass.getConstructor().newInstance());\n            } catch (NoSuchMethodException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Standard logical type '%s' does not have a zero-argument constructor.\", urn),\n                  e);\n            } catch (IllegalAccessException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Standard logical type '%s' has a zero-argument constructor, but it is not accessible.\",\n                      urn),\n                  e);\n            } catch (ReflectiveOperationException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Error instantiating logical type '%s' with zero-argument constructor.\", urn),\n                  e);\n            }\n          }\n        }\n        // Special-case for DATETIME and DECIMAL which are logical types in portable representation,","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java#L432-L468","documentation":"For standard logical types without an argument, SchemaTranslation instantiates the class via its no-arg constructor; if none exists (NoSuchMethodException) it throws RuntimeException 'does not have a zero-argument constructor'.","triggerScenarios":"Decoding an argument-less logical type whose URN maps to a class with only parameterized constructors.","commonSituations":"Refactored logical type classes that lost their default constructor; classes with final fields requiring constructor args; Kotlin/Scala classes without explicit no-arg constructors.","solutions":["Add a public no-arg constructor to the logical type class.","Register the correct implementation class for the URN (one that has a default constructor).","If the type actually needs an argument, encode it as an argumented logical type so of() is used instead.","Catch the RuntimeException at decode and report a schema compatibility error."],"exampleFix":"// before\nclass IdLogicalType { public IdLogicalType(int seed){...} }\n// after\nclass IdLogicalType { public IdLogicalType(){} public IdLogicalType(int seed){...} }","handlingStrategy":"validation","validationCode":"try { logicalTypeClass.getConstructor(); return true; }\ncatch (NoSuchMethodException e) { return false; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a public no-arg constructor in argument-less logical types.","Keep a default constructor when adding parameterized ones.","Map URNs to classes that satisfy Beam's instantiation contract.","Add round-trip proto tests for every custom logical type."],"tags":["java","apache-beam","reflection","constructor"],"backgroundTag":"invalid-constructor-argument","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"}