{"record":{"id":"99f4e319d7f71990","repo":"apache/cassandra","slug":"non-empty-table-is-required","errorCode":null,"errorMessage":"non-empty table is required","messagePattern":"non-empty table is required","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/SchemaProvider.java","lineNumber":98,"sourceCode":"        return getTableMetadata(descriptor.ksname, descriptor.cfname).ref;\n    }\n\n    default ViewMetadata getView(String keyspaceName, String viewName)\n    {\n        assert keyspaceName != null;\n        KeyspaceMetadata ksm = distributedKeyspaces().getNullable(keyspaceName);\n        return (ksm == null) ? null : ksm.views.getNullable(viewName);\n    }\n\n    default Keyspaces getNonLocalStrategyKeyspaces()\n    {\n        return distributedKeyspaces().filter(keyspace -> keyspace.params.replication.klass != LocalStrategy.class);\n    }\n\n    default TableMetadata validateTable(String keyspaceName, String tableName)\n    {\n        if (tableName.isEmpty())\n            throw new InvalidRequestException(\"non-empty table is required\");\n\n        KeyspaceMetadata keyspace = getKeyspaceMetadata(keyspaceName);\n        if (keyspace == null)\n            throw new KeyspaceNotDefinedException(String.format(\"keyspace %s does not exist\", keyspaceName));\n\n        TableMetadata metadata = keyspace.getTableOrViewNullable(tableName);\n        if (metadata == null)\n            throw new InvalidRequestException(String.format(\"table %s does not exist\", tableName));\n\n        return metadata;\n    }\n\n    default ColumnFamilyStore getColumnFamilyStoreInstance(TableId id)\n    {\n        TableMetadata metadata = getTableMetadata(id);\n        if (metadata == null)\n            return null;\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/SchemaProvider.java#L80-L116","documentation":"SchemaProvider.validateTable rejects an empty table name with InvalidRequestException('non-empty table is required') before any keyspace lookup. The API requires a concrete, non-empty table identifier to resolve metadata.","triggerScenarios":"Calling validateTable (directly or via query processing paths that resolve a statement's table) with tableName == \"\" — e.g. a parsed statement whose table name defaulted to empty, or programmatic callers passing an empty string.","commonSituations":"Statement parsing bugs building empty table names; internal tooling or drivers invoking metadata APIs with unset table variables; templated queries where the table placeholder was not substituted.","solutions":["Pass a valid, non-empty table name to the statement or API call.","Fix upstream statement parsing/templating so the table name is populated.","Add a client-side check that the table name is non-empty before issuing the operation."],"exampleFix":"// before\nTableMetadata tm = schema.validateTable(keyspace, tableName); // tableName == \"\"\n// after\nif (tableName == null || tableName.isEmpty()) throw new IllegalArgumentException(\"table name required\");\nTableMetadata tm = schema.validateTable(keyspace, tableName);","handlingStrategy":"validation","validationCode":"if (tableName == null || tableName.isEmpty())\n    throw new IllegalArgumentException(\"Table name must be a non-empty string\");\nif (!tableName.matches(\"\\\\w+\"))\n    throw new IllegalArgumentException(\"Table name contains illegal characters: \" + tableName);","typeGuard":"boolean isValidTableName(String name) {\n    return name != null && !name.isEmpty() && name.matches(\"[a-zA-Z_][a-zA-Z0-9_]*\");\n}","tryCatchPattern":null,"preventionTips":["Validate statement templates so table-name placeholders are always substituted.","Fail fast in application code when a table name variable is null/empty.","Add unit tests covering statement construction with missing table identifiers."],"tags":["validation","invalid-request","table-name"],"backgroundTag":"empty-required-field","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}