{"record":{"id":"d0f5f11cf9b68539","repo":"apache/beam","slug":"error-instantiating-logical-type-s-with-of-s-method","errorCode":null,"errorMessage":"Error instantiating logical type '%s' with of('%s') method.","messagePattern":"Error instantiating logical type '(.+?)' with of\\('(.+?)'\\) method\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java","lineNumber":439,"sourceCode":"            String objectName = clazz.getName();\n            try {\n              return FieldType.logicalType(\n                  logicalTypeClass.cast(\n                      logicalTypeClass.getMethod(\"of\", clazz).invoke(null, fieldValue)));\n            } catch (NoSuchMethodException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Standard logical type '%s' does not have a static of('%s') method.\",\n                      urn, objectName),\n                  e);\n            } 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.\",","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java#L421-L457","documentation":"If the reflective call to the logical type's static of(%) method throws (InvocationTargetException), SchemaTranslation wraps it as RuntimeException 'Error instantiating logical type ... with of(...) method'. The of() factory itself failed at runtime while validating or constructing the value.","triggerScenarios":"Decoding a logical type where of(bootstrapValue) throws — e.g. the serialized argument value is invalid for the type's own validation (bad date string, out-of-range value, rejected null).","commonSituations":"Data written with values the current type definition no longer accepts; custom validation added to of() after data was written; locale/version-dependent parsing failures.","solutions":["Read the cause chain (InvocationTargetException target) to see the factory's own exception; fix the offending serialized value.","Relax or align validation in of() to accept values produced by the writer version.","Re-encode or filter records whose argument values are invalid.","Catch this RuntimeException when decoding to quarantine bad records instead of aborting the pipeline."],"exampleFix":"// before\npublic static SqlTypes of(String v){ return new SqlTypes(LocalDate.parse(v)); } // throws on bad data\n// after\npublic static SqlTypes of(String v){\n  try { return new SqlTypes(LocalDate.parse(v)); }\n  catch (DateTimeParseException e){ return SqlTypes.defaultValue(); }\n}","handlingStrategy":"try-catch","validationCode":"try { logicalTypeClass.getMethod(\"of\", argClass).invoke(null, value); return true; }\ncatch (InvocationTargetException e) { return false; }\ncatch (Exception e) { return false; }","typeGuard":null,"tryCatchPattern":"try {\n  decodeSchema(proto);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Error instantiating logical type\")) {\n    quarantine(record, e.getCause());\n  } else throw e;\n}","preventionTips":["Validate serialized bootstrap values against of()'s expectations.","Keep of() validation consistent with historical written data.","Filter/upgrade records produced by older incompatible versions.","Test decode of production snapshots in CI."],"tags":["java","apache-beam","reflection","logical-type"],"backgroundTag":"invalid-argument-value","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"}