{"record":{"id":"c1eaab70fc672287","repo":"apache/seatunnel","slug":"template-cannot-be-null-or-empty","errorCode":null,"errorMessage":"Template cannot be null or empty","messagePattern":"Template cannot be null or empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveTableTemplateUtils.java","lineNumber":154,"sourceCode":"                java.util.regex.Pattern.compile(\n                        partitionPattern, java.util.regex.Pattern.CASE_INSENSITIVE);\n        java.util.regex.Matcher matcher = pattern.matcher(template);\n\n        if (matcher.find()) {\n            String partitionClause = matcher.group(1);\n            // Extract field names (basic parsing)\n            return java.util.Arrays.stream(partitionClause.split(\",\"))\n                    .map(field -> field.trim().split(\"\\\\s+\")[0].replaceAll(\"`\", \"\"))\n                    .collect(Collectors.toList());\n        }\n\n        return java.util.Collections.emptyList();\n    }\n\n    /** Validate template syntax (basic validation) */\n    public static void validateTemplate(String template) {\n        if (template == null || template.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"Template cannot be null or empty\");\n        }\n\n        // Check for required CREATE TABLE statement\n        if (!template.toUpperCase().contains(\"CREATE TABLE\")) {\n            throw new IllegalArgumentException(\"Template must contain CREATE TABLE statement\");\n        }\n\n        // Check for required variables\n        if (!template.contains(\"${database}\") || !template.contains(\"${table}\")) {\n            throw new IllegalArgumentException(\n                    \"Template must contain ${database} and ${table} variables\");\n        }\n    }\n\n    /** Extract LOCATION path from template. If it contains ${table_location}, replace it. */\n    public static String extractLocationFromTemplate(\n            String template, String database, String table) {\n        if (template == null) {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveTableTemplateUtils.java#L136-L172","documentation":"IllegalArgumentException thrown by HiveTableTemplateUtils.validateTemplate when the supplied create-table template is null or only whitespace. The template is the user-provided DDL used to create Hive tables, so an empty one can never produce valid SQL.","triggerScenarios":"Calling validateTemplate(null) or validateTemplate(\"   \"); passing an empty template option from config or reading an empty template file/string in buildCreateTableSQL flows.","commonSituations":"Template option left empty in job config; template loaded from a file that exists but is empty; string substitution (env var, placeholder) resolving to blank.","solutions":["Provide a valid DDL template containing a CREATE TABLE statement","Check the config key/file that supplies the template is non-empty","Trim-inspect the template string before invoking the catalog operation","Add a startup validation of the template in the source/sink factory"],"exampleFix":"// before\nString template = config.get(TEMPLATE_OPTION); // may be empty\n// after\nString template = config.get(TEMPLATE_OPTION);\nif (template == null || template.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"hive.table-create-template must be set\");\n}","handlingStrategy":"type-guard","validationCode":"if (template == null || template.trim().isEmpty()) { template = DEFAULT_HIVE_TEMPLATE; }","typeGuard":"boolean templatePresent = template != null && !template.trim().isEmpty();","tryCatchPattern":"try { validateTemplate(template); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(\"Provide hive.table-create-template: \" + e.getMessage()); }","preventionTips":["Define a sensible default template in the connector","Validate template at config parse time","Check template source files are non-empty","Guard env-var substitution against blank results"],"tags":["hive","template","validation"],"backgroundTag":"empty-required-field","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}