{"record":{"id":"2bcb00c833a9e642","repo":"apache/iceberg","slug":"cannot-find-table-s-to-drop","errorCode":null,"errorMessage":"Cannot find table %s to drop","messagePattern":"Cannot find table (.+?) to drop","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":404,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/dynamodb/DynamoDbCatalog.java","lineNumber":387,"sourceCode":"      lastEvaluatedKey = response.lastEvaluatedKey();\n    } while (!lastEvaluatedKey.isEmpty());\n    return identifiers;\n  }\n\n  @Override\n  public boolean dropTable(TableIdentifier identifier, boolean purge) {\n    Map<String, AttributeValue> key = tablePrimaryKey(identifier);\n    try {\n      GetItemResponse response =\n          dynamo.getItem(\n              GetItemRequest.builder()\n                  .tableName(awsProperties.dynamoDbTableName())\n                  .consistentRead(true)\n                  .key(key)\n                  .build());\n\n      if (!response.hasItem()) {\n        throw new NoSuchTableException(\"Cannot find table %s to drop\", identifier);\n      }\n\n      TableOperations ops = newTableOps(identifier);\n      TableMetadata lastMetadata = null;\n      if (purge) {\n        try {\n          lastMetadata = ops.current();\n        } catch (NotFoundException e) {\n          LOG.warn(\n              \"Failed to load table metadata for table: {}, continuing drop without purge\",\n              identifier,\n              e);\n        }\n      }\n      dynamo.deleteItem(\n          DeleteItemRequest.builder()\n              .tableName(awsProperties.dynamoDbTableName())\n              .key(tablePrimaryKey(identifier))","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/dynamodb/DynamoDbCatalog.java#L369-L405","documentation":"DynamoDbCatalog.dropTable() first reads the table's item with a consistent GetItem; if no item is found it throws NoSuchTableException with this message. Dropping requires the table row to exist because the catalog must read its metadata location before removing or purging it.","triggerScenarios":"Calling catalog.dropTable(identifier) or dropTable(identifier, purge) when the DynamoDB catalog table contains no item for the given table identifier — the table was already dropped, never existed, or the identifier is wrong.","commonSituations":"Double-execution of a drop in retry/race scenarios; referencing a table in a different environment or wrong DynamoDB table name; case-sensitive identifier mismatches; concurrent jobs dropping the same table.","solutions":["Guard with catalog.tableExists(identifier) before dropping, or treat a false dropTable() return value as already-dropped (dropTable returns boolean).","Verify the identifier and catalog configuration (DynamoDB table name, region) match the environment that owns the table.","Catch org.apache.iceberg.exceptions.NoSuchTableException and treat it as success in idempotent cleanup code."],"exampleFix":"// before\nboolean dropped = catalog.dropTable(TableIdentifier.of(\"analytics\", \"events\"), true);\n\n// after\nTableIdentifier id = TableIdentifier.of(\"analytics\", \"events\");\nif (catalog.tableExists(id)) {\n  catalog.dropTable(id, true);\n}","handlingStrategy":"validation","validationCode":"TableIdentifier id = TableIdentifier.of(\"analytics\", \"events\");\nif (catalog.tableExists(id)) {\n  catalog.dropTable(id, true);\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.dropTable(id, true);\n} catch (NoSuchTableException e) {\n  // already dropped; idempotent cleanup\n}","preventionTips":["Treat dropTable's boolean return and NoSuchTableException as 'already gone' in retries","Verify the identifier and environment before destructive operations","Avoid concurrent drops of the same table"],"tags":["aws","dynamodb","catalog","table-not-found"],"backgroundTag":"resource-not-found","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"}