{"record":{"id":"5d9060a5681a40c2","repo":"apache/druid","slug":"catalogexception-validationerror-e-wraps-iae-dru","errorCode":null,"errorMessage":"CatalogException.validationError(e) (wraps IAE/DruidException validation message)","messagePattern":"CatalogException\\.validationError\\(e\\) \\(wraps IAE/DruidException validation message\\)","errorType":"validation","errorClass":"CatalogException","httpStatus":400,"severity":"error","filePath":"extensions-core/druid-catalog/src/main/java/org/apache/druid/catalog/http/CatalogResource.java","lineNumber":153,"sourceCode":"      @PathParam(\"schema\") String schemaName,\n      @PathParam(\"name\") String tableName,\n      TableSpec spec,\n      @QueryParam(\"version\") long version,\n      @QueryParam(\"overwrite\") boolean overwrite,\n      @Context final HttpServletRequest req\n  )\n  {\n    try {\n      final SchemaSpec schema = validateSchema(schemaName, true);\n      validateTableName(tableName);\n      authorizeTable(schema, tableName, ACTIONS_FOR_WRITE, req);\n      validateTableSpec(schema, spec);\n      final TableMetadata table = TableMetadata.newTable(TableId.of(schemaName, tableName), spec);\n      try {\n        catalog.validate(table);\n      }\n      catch (IAE | DruidException e) {\n        throw CatalogException.validationError(e);\n      }\n\n      long newVersion;\n      if (version != 0) {\n        // A version is provided. Update that version (only).\n        newVersion = catalog.tables().update(table, version);\n      } else {\n        try {\n          // No version. Create the table.\n          newVersion = catalog.tables().create(table);\n        }\n        catch (DuplicateKeyException e) {\n          // Table exists\n          if (overwrite) {\n            // User wants to overwrite, so do so.\n            newVersion = catalog.tables().replace(table);\n          } else {\n            throw e;","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/druid-catalog/src/main/java/org/apache/druid/catalog/http/CatalogResource.java#L135-L171","documentation":"CatalogResource.postTable validates a new table spec via catalog.validate(table); validation failures surface as IAE or DruidException and are rethrown as CatalogException.validationError(e), which wraps the original validation message. This is the catalog's way of rejecting table specs that violate schema/defn rules during table creation.","triggerScenarios":"POST to the catalog table resource with a table spec that fails spec/schema validation, e.g. invalid column definitions, missing required properties, or a spec type the validator rejects.","commonSituations":"Hand-written table JSON missing required fields; column specs incompatible with the schema's rules; copy-pasted specs from other schemas; API clients building specs programmatically with wrong types.","solutions":["Read the wrapped validation message and fix the offending field in the table spec.","Validate the spec offline by calling spec.validate() in a test or CLI before posting.","Ensure the spec type is supported by the target schema (accepted via schema.accepts).","Compare against a known-good example spec of the same type."],"exampleFix":"// before: spec missing required column definition\n// {\"type\":\"avro\",\"columns\":[]}\n// after\n// {\"type\":\"avro\",\"columns\":[{\"name\":\"ts\",\"type\":\"long\",\"sqlType\":\"BIGINT\"}]}","handlingStrategy":"try-catch","validationCode":"// client-side pre-check\n// ensure spec JSON has required fields and a type accepted by the target schema before POSTing","typeGuard":null,"tryCatchPattern":"try { catalogResource.postTable(schemaName, tableName, 0, specJson); }\ncatch (CatalogException e) { if (e.isValidation()) { log.error(\"Invalid table spec: {}\", e.getMessage()); } else { throw e; } }","preventionTips":["Validate specs against a schema example before POSTing.","Use typed spec builders instead of hand-written JSON.","Keep spec templates per schema type in source control."],"tags":["catalog","http","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}