fix(dynamodb): drop the table name from the PartiQL missing table error, and treat a CREATING table as missing (#7158)

This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-10-31 22:52:23 -04:00
1 parent e77823feed
commit 89ecb594e1
5 files changed
+77 -13

No files matched your search

@@ -46,7 +46,7 @@ class DynamoDbPartiQLHandler {
// --- SELECT ---
private Result executeSelect(Stmt.Select stmt, PartiQLExecuteContext ctx, String region) {
TableDefinition table = service.describeTable(stmt.table(), region);
TableDefinition table = service.requireTableForItemCall(stmt.table(), region);
// A vector index is reachable through SearchVectors alone, and PartiQL says so
// rather than reporting the index as missing.
if (table.findVectorIndex(stmt.index()).isPresent()) {
@@ -544,7 +544,7 @@ class DynamoDbPartiQLHandler {
// --- INSERT ---
private Result executeInsert(Stmt.Insert stmt, String region) {
TableDefinition table = service.describeTable(stmt.table(), region);
TableDefinition table = service.requireTableForItemCall(stmt.table(), region);
String pkName = table.getPartitionKeyName();
ObjectNode item = mapper.createObjectNode();
@@ -564,7 +564,7 @@ class DynamoDbPartiQLHandler {
private Result executeUpdate(Stmt.Update stmt, String returnValuesOnConditionCheckFailure, String region) {
requireNoIndexQualifier(stmt.index());
TableDefinition table = service.describeTable(stmt.table(), region);
TableDefinition table = service.requireTableForItemCall(stmt.table(), region);
requireOneValuePerKey(table, stmt.where());
ObjectNode key = buildKey(table, stmt.where());
@@ -619,7 +619,7 @@ class DynamoDbPartiQLHandler {
private Result executeDelete(Stmt.Delete stmt, String returnValuesOnConditionCheckFailure, String region) {
requireNoIndexQualifier(stmt.index());
TableDefinition table = service.describeTable(stmt.table(), region);
TableDefinition table = service.requireTableForItemCall(stmt.table(), region);
requireOneValuePerKey(table, stmt.where());
ObjectNode key = buildKey(table, stmt.where());
@@ -652,7 +652,7 @@ class DynamoDbPartiQLHandler {
case Stmt.Delete del -> del.index();
default -> null;
});
Optional<TableDefinition> found = service.findTable(stmt.table(), region);
Optional<TableDefinition> found = service.findTableForItemCall(stmt.table(), region);
if (found.isEmpty()) {
return TransactMember.TABLE_NOT_FOUND;
}
@@ -767,7 +767,7 @@ class DynamoDbPartiQLHandler {
}
TransactMember toTransactGetItem(Stmt.Select stmt, String region) {
Optional<TableDefinition> found = service.findTable(stmt.table(), region);
Optional<TableDefinition> found = service.findTableForItemCall(stmt.table(), region);
if (found.isEmpty()) {
return TransactMember.TABLE_NOT_FOUND;
}
@@ -4928,12 +4928,11 @@ public class DynamoDbService {
}
private TableDefinition requireActiveTable(String storageKey) {
TableDefinition table = tableStore.get(storageKey)
.orElseThrow(DynamoDbService::itemCallResourceNotFound);
if ("CREATING".equals(table.getTableStatus())) {
throw itemCallResourceNotFound();
}
return table;
return findActiveTable(storageKey).orElseThrow(DynamoDbService::itemCallResourceNotFound);
}
private Optional<TableDefinition> findActiveTable(String storageKey) {
return tableStore.get(storageKey).filter(table -> !"CREATING".equals(table.getTableStatus()));
}
/** Resolves a table for an item call, so a miss reports the message AWS uses there. */
@@ -4942,6 +4941,11 @@ public class DynamoDbService {
return requireActiveTable(regionKey(region, canonicalTableName));
}
/** Finds a table for an item call, which treats a CREATING table as absent. */
public Optional<TableDefinition> findTableForItemCall(String tableName, String region) {
return findActiveTable(regionKey(region, canonicalTableName(region, tableName)));
}
/**
* Resolves the table for an item call and validates the key it names, without reading the
* stored item, so a caller can report table and key errors before its own validation.
@@ -3841,10 +3841,10 @@ public class NativeDynamoDbJsonHandler {
// WHERE clauses are rejected per statement (characterised on real AWS,
// eu-west-1, 2026-09-02).
private void requireBatchSelectReadsByKey(DynamoDbPartiQLParser.Stmt.Select select, String region) {
TableDefinition table = dynamoDbService.requireTableForItemCall(select.table(), region);
if (select.index() != null) {
throw batchSelectNeedsKey();
}
TableDefinition table = dynamoDbService.requireTableForItemCall(select.table(), region);
DynamoDbPartiQLHandler.requireReadsWithinLimit(table, select.where());
if (!DynamoDbPartiQLHandler.namesOnlyTheKey(table, select.where())) {
throw batchSelectNeedsKey();