{"record":{"id":"d9a359c75496ab47","repo":"OtterMind/Chat2DB","slug":"presto-table-name-must-not-be-blank","errorCode":null,"errorMessage":"Presto table name must not be blank","messagePattern":"Presto table name must not be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-presto/src/main/java/ai/chat2db/plugin/presto/PrestoMetaData.java","lineNumber":27,"sourceCode":"\npublic class PrestoMetaData extends DefaultMetaService implements IDbMetaData {\n\n    @Override\n    public String tableDDL(Connection connection, String databaseName, String schemaName, String tableName) {\n        ISQLIdentifierProcessor identifierProcessor = getSQLIdentifierProcessor();\n        String sql = buildShowCreateTableSql(identifierProcessor, databaseName, 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(ISQLIdentifierProcessor identifierProcessor, String catalogName,\n                                          String schemaName, String tableName) {\n        if (isBlank(tableName)) {\n            throw new IllegalArgumentException(\"Presto table name must not be blank\");\n        }\n\n        boolean hasCatalog = !isBlank(catalogName);\n        boolean hasSchema = !isBlank(schemaName);\n        if (hasCatalog && !hasSchema) {\n            throw new IllegalArgumentException(\"Presto schema name is required when catalog name is provided\");\n        }\n\n        StringBuilder qualifiedName = new StringBuilder();\n        if (hasCatalog) {\n            qualifiedName.append(identifierProcessor.quoteIdentifierAlways(catalogName)).append('.');\n        }\n        if (hasSchema) {\n            qualifiedName.append(identifierProcessor.quoteIdentifierAlways(schemaName)).append('.');\n        }\n        qualifiedName.append(identifierProcessor.quoteIdentifierAlways(tableName));\n        return \"SHOW CREATE TABLE \" + qualifiedName;\n    }","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-presto/src/main/java/ai/chat2db/plugin/presto/PrestoMetaData.java#L9-L45","documentation":"Thrown by PrestoMetaData.buildShowCreateTableSql when the tableName parameter is null or blank (whitespace-only). This method constructs the SHOW CREATE TABLE SQL for Presto/Trino. A blank table name makes the SQL syntactically invalid, so it is rejected before execution. The check uses isBlank which tests for null or all-whitespace strings.","triggerScenarios":"Calling PrestoMetaData.tableDDL(connection, databaseName, schemaName, tableName) where tableName is null, empty, or contains only whitespace. The validation runs in buildShowCreateTableSql at line 26 before the SQL is sent to the connection.","commonSituations":"A UI selection event that fires before a table is fully selected; a null table name from a metadata tree node; programmatic callers passing an unvalidated identifier.","solutions":["Validate that tableName is non-blank before calling tableDDL","Guard the UI so tableDDL is only invoked when a concrete table node is selected","Return early or skip if tableName is null or blank at the call site"],"exampleFix":"// before\nString ddl = metaData.tableDDL(conn, catalog, schema, \"\");\n\n// after\nif (tableName == null || tableName.isBlank()) {\n    throw new IllegalArgumentException(\"Table name required\");\n}\nString ddl = metaData.tableDDL(conn, catalog, schema, tableName);","handlingStrategy":"validation","validationCode":"if (tableName == null || tableName.isBlank()) {\n    throw new IllegalArgumentException(\"Presto table name must not be blank\");\n}\nString sql = PrestoMetaData.buildShowCreateTableSql(processor, catalog, schema, tableName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate tableName is non-blank before calling tableDDL","Guard UI so tableDDL is only called when a concrete table is selected","Return early in the controller or service if the table name is missing"],"tags":["presto","metadata","validation","identifier"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}