{"record":{"id":"00d201ee36d45632","repo":"OtterMind/Chat2DB","slug":"redshift-table-name-must-not-be-empty","errorCode":null,"errorMessage":"Redshift table name must not be empty","messagePattern":"Redshift table name must not be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-redshift/src/main/java/ai/chat2db/plugin/redshift/RedshiftMetaData.java","lineNumber":42,"sourceCode":"    @Override\n    public ISQLIdentifierProcessor getSQLIdentifierProcessor() {\n        return RedshiftIdentifierProcessor.INSTANCE;\n    }\n\n    @Override\n    public String tableDDL(Connection connection, String databaseName, String schemaName, String tableName) {\n        String sql = buildShowCreateTableSql(schemaName, tableName);\n        return DefaultSQLExecutor.getInstance().execute(connection, sql, resultSet -> {\n            if (resultSet.next()) {\n                return resultSet.getString(1);\n            }\n            return null;\n        });\n    }\n\n    static String buildShowCreateTableSql(String schemaName, String tableName) {\n        if (tableName == null || tableName.isEmpty()) {\n            throw new IllegalArgumentException(\"Redshift table name must not be empty\");\n        }\n        String qualifiedName = schemaName == null || schemaName.isEmpty()\n                ? RedshiftIdentifierProcessor.INSTANCE.quoteIdentifierAlways(tableName)\n                : RedshiftIdentifierProcessor.INSTANCE.quoteIdentifierAlways(schemaName) + \".\"\n                + RedshiftIdentifierProcessor.INSTANCE.quoteIdentifierAlways(tableName);\n        return \"SHOW CREATE TABLE \" + qualifiedName;\n    }\n\n    @Override\n    public List<TableIndex> indexes(Connection connection, String databaseName, String schemaName, String tableName) {\n        return DefaultSQLExecutor.getInstance().indexes(connection, StringUtils.isEmpty(databaseName) ? null : databaseName, StringUtils.isEmpty(schemaName) ? null : schemaName, tableName);\n    }\n\n    @Override\n    public Function function(Connection connection, @NotEmpty String databaseName, String schemaName,\n                             String functionName) {\n        return DefaultSQLExecutor.getInstance().preExecute(connection, FUNCTION_DEFINITION, new String[]{functionName,schemaName}, resultSet -> {\n            Function function = new Function();","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-redshift/src/main/java/ai/chat2db/plugin/redshift/RedshiftMetaData.java#L24-L60","documentation":"Thrown by RedshiftMetaData.buildShowCreateTableSql when tableName is null or empty. This method constructs a SHOW CREATE TABLE SQL for Redshift (which inherits from PostgreSQL). A null or empty table name makes the qualified identifier invalid. Note: unlike PrestoMetaData which uses isBlank (also catches whitespace-only), this uses a simpler null-or-isEmpty check.","triggerScenarios":"Calling RedshiftMetaData.tableDDL(connection, databaseName, schemaName, tableName) where tableName is null or has length 0. The validation runs in buildShowCreateTableSql at line 41.","commonSituations":"A UI selection event fired before a table node is chosen; a null table name from a metadata tree; programmatic callers passing an unvalidated identifier; a whitespace-only table name that passes this check but would fail downstream.","solutions":["Validate that tableName is non-null and non-empty before calling tableDDL","Guard the UI so tableDDL is only invoked with a concrete table selection","Consider also checking isBlank to catch whitespace-only names that pass isEmpty"],"exampleFix":"// before\nString ddl = metaData.tableDDL(conn, db, schema, \"\");\n\n// after\nif (tableName == null || tableName.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"Table name required\");\n}\nString ddl = metaData.tableDDL(conn, db, schema, tableName);","handlingStrategy":"validation","validationCode":"if (tableName == null || tableName.isEmpty()) {\n    throw new IllegalArgumentException(\"Redshift table name must not be empty\");\n}\n// Also catch whitespace-only names that pass isEmpty but would fail downstream:\nif (tableName.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"Table name is whitespace-only\");\n}\nString sql = RedshiftMetaData.buildShowCreateTableSql(schemaName, tableName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate tableName is non-null and non-empty before calling tableDDL","Also check isBlank to catch whitespace-only names","Guard the UI so tableDDL is only called with a concrete table selection"],"tags":["redshift","metadata","validation","identifier"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}