{"record":{"id":"c37cd933b2cd985d","repo":"apache/iceberg","slug":"invalid-identifier-s","errorCode":null,"errorMessage":"Invalid identifier: %s","messagePattern":"Invalid identifier: (.+?)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java","lineNumber":251,"sourceCode":"\n  @Override\n  protected String defaultWarehouseLocation(TableIdentifier tableIdentifier) {\n    String tableName = tableIdentifier.name();\n    StringBuilder sb = new StringBuilder();\n\n    sb.append(warehouseLocation).append('/');\n    for (String level : tableIdentifier.namespace().levels()) {\n      sb.append(level).append('/');\n    }\n    sb.append(tableName);\n\n    return sb.toString();\n  }\n\n  @Override\n  public boolean dropTable(TableIdentifier identifier, boolean purge) {\n    if (!isValidIdentifier(identifier)) {\n      throw new NoSuchTableException(\"Invalid identifier: %s\", identifier);\n    }\n\n    Path tablePath = new Path(defaultWarehouseLocation(identifier));\n    TableOperations ops = newTableOps(identifier);\n    TableMetadata lastMetadata = ops.current();\n    try {\n      if (lastMetadata == null) {\n        LOG.debug(\"Not an iceberg table: {}\", identifier);\n        return false;\n      } else {\n        if (purge) {\n          // Since the data files and the metadata files may store in different locations,\n          // so it has to call dropTableData to force delete the data file.\n          CatalogUtil.dropTableData(ops.io(), lastMetadata);\n        }\n        return fs.delete(tablePath, true /* recursive */);\n      }\n    } catch (IOException e) {","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java#L233-L269","documentation":"HadoopCatalog.dropTable throws NoSuchTableException when the given TableIdentifier fails isValidIdentifier. In this catalog, isValidIdentifier effectively always returns true (HadoopCatalog.java:224), so in practice this error is nearly unreachable via dropTable directly; it is a defensive guard meant for subclasses with identifier constraints.","triggerScenarios":"Calling catalog.dropTable(identifier, purge) with an identifier that a subclass's isValidIdentifier rejects (e.g. identifiers with unsupported characters, reserved names, or wrong namespace shape when the base method is overridden).","commonSituations":"Using a subclass of HadoopCatalog with stricter identifier rules, passing identifiers built from unvalidated user input, or identifiers containing path-hostile characters like '/', '..', or empty segments.","solutions":["Validate the TableIdentifier (non-empty name, no path-separator characters like '/' or '..') before calling dropTable.","Check the subclass implementation of isValidIdentifier to learn its exact rules.","Confirm you are calling dropTable on the intended catalog instance, not one with stricter identifier validation.","Handle NoSuchTableException and surface a corrected identifier to the caller."],"exampleFix":"// before: blind drop\ncatalog.dropTable(TableIdentifier.of(ns, userInput), false);\n\n// after: validate first\nif (userInput.contains(\"/\") || userInput.isEmpty()) {\n  throw new IllegalArgumentException(\"Invalid table name: \" + userInput);\n}\ncatalog.dropTable(TableIdentifier.of(ns, userInput), false);","handlingStrategy":"validation","validationCode":"boolean valid = ident != null && !ident.name().isEmpty() && !ident.name().contains(\"/\");\nif (!valid) throw new IllegalArgumentException(\"Invalid identifier: \" + ident);","typeGuard":null,"tryCatchPattern":"try { catalog.dropTable(ident, false); } catch (NoSuchTableException e) { // surface corrected identifier to caller }","preventionTips":["Sanitize table names from user input","Reject path separators and empty segments","Read the catalog subclass's isValidIdentifier rules"],"tags":["identifier","validation","catalog","drop-table"],"backgroundTag":"invalid-identifier","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}