{"record":{"id":"786c8de2e125e103","repo":"apache/beam","slug":"validationexception","errorCode":null,"errorMessage":"ValidationException","messagePattern":"ValidationException","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/context/FailureCollectorWrapper.java","lineNumber":66,"sourceCode":"    // anything in our case\n    List<ValidationFailure> schemaValidationFailures = new ArrayList<>();\n    for (ValidationFailure failure : failuresCollection) {\n      List<ValidationFailure.Cause> causes = failure.getCauses();\n      if (causes != null) {\n        for (ValidationFailure.Cause cause : causes) {\n          String inputField = cause.getAttribute(CauseAttributes.INPUT_SCHEMA_FIELD);\n          if (BatchContextImpl.DEFAULT_SCHEMA_FIELD_NAME.equals(inputField)) {\n            schemaValidationFailures.add(failure);\n          }\n        }\n      }\n    }\n    failuresCollection.removeAll(schemaValidationFailures);\n    if (failuresCollection.isEmpty()) {\n      return new ValidationException(this.failuresCollection);\n    }\n\n    throw new ValidationException(this.failuresCollection);\n  }\n\n  @Override\n  public List<ValidationFailure> getValidationFailures() {\n    return this.failuresCollection;\n  }\n}\n","sourceCodeStart":48,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/context/FailureCollectorWrapper.java#L48-L74","documentation":"FailureCollectorWrapper.getOrThrowException aggregates validation failures collected during CDAP pipeline translation; once checks (such as removing schema-validation failures) are done, any remaining failures cause a ValidationException carrying the whole failure collection to be thrown. This is the standard CDAP failure-collector pattern: failures are gathered during validation and thrown together at a checkpoint.","triggerScenarios":"Any addFailure(...) on the wrapped collector followed by getOrThrowException with outstanding failures — e.g., schema/field validation problems detected while expanding a CDAP source/sink (missing fields, type mismatches between the schema and the plugin config).","commonSituations":"Mismatch between the declared schema and actual plugin config (renamed or removed fields); invalid option values surfaced during pipeline validation; running a pipeline where a CDAP plugin reports configuration errors at expansion time.","solutions":["Inspect the ValidationException's failure collection; each entry names the offending field/property and reason","Fix the schema/config mismatch reported (align field names and types between the Beam schema and plugin config)","If the failure is a schema-field-only validation you intentionally want to ignore, adjust config so it passes instead of suppressing","Run with validation logging enabled to see all failures before the throw"],"exampleFix":"// before\nschema has field \"user_name\" but plugin config references \"username\"\n// after\nalign plugin config field \"username\" to schema field \"user_name\" (or vice versa) so no validation failures remain","handlingStrategy":"try-catch","validationCode":"// before getOrThrowException\nFailureCollectorWrapper collector = ...;\nif (!collector.getValidationFailures().isEmpty()) {\n  collector.getValidationFailures().forEach(f -> LOG.warn(\"Validation failure: {}\", f));\n}","typeGuard":null,"tryCatchPattern":"try {\n  expand(...);\n} catch (ValidationException e) {\n  e.getFailures().forEach(f -> LOG.error(\"CDAP validation: {}\", f.getMessage()));\n  throw new IllegalArgumentException(\"Invalid CDAP plugin config/schema: see logged failures\", e);\n}","preventionTips":["Align the Beam schema field names/types with the plugin config before expansion","Log all validation failures early (getValidationFailures) instead of waiting for the throw","Run pipeline expansion in CI to catch schema drift between plugin versions"],"tags":["java","cdap","validation","schema","failure-collector"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}