fix(rds): return DBSubnetGroupNotFoundFault for missing DescribeDBSubnetGroups name (#1870)

DescribeDBSubnetGroups with a missing DBSubnetGroupName returned HTTP 200 and an empty list; reuse resolveDbSubnetGroupView so AWS clients get a 404 fault instead.
This commit is contained in:
Leandro-ft authored and GitHub committed 2026-07-15 00:37:59 -04:00
1 parent a7d33ba885
commit 1ba15f0ce7
3 files changed
+38 -2

No files matched your search

@@ -770,6 +770,21 @@ class RdsQueryHandlerTest {
verify(service).listDbSubnetGroups(null, "us-west-2");
}
@Test
void describeDbSubnetGroups_missingNameReturnsNotFoundFault() {
when(service.listDbSubnetGroups("does-not-exist", null))
.thenThrow(new AwsException("DBSubnetGroupNotFoundFault",
"DB subnet group does-not-exist not found.", 404));
MultivaluedMap<String, String> p = params();
p.add("DBSubnetGroupName", "does-not-exist");
Response response = handler.handle("DescribeDBSubnetGroups", p);
assertEquals(404, response.getStatus());
assertTrue(((String) response.getEntity()).contains("DBSubnetGroupNotFoundFault"));
}
// ──────────────────────────── Helpers ────────────────────────────
private static MultivaluedMap<String, String> params() {
@@ -293,7 +293,25 @@ class RdsServiceTest {
assertEquals(1, rdsService.listDbSubnetGroups("sample-db-subnets").size());
rdsService.deleteDbSubnetGroup("sample-db-subnets");
assertTrue(rdsService.listDbSubnetGroups("sample-db-subnets").isEmpty());
AwsException missing = assertThrows(AwsException.class,
() -> rdsService.listDbSubnetGroups("sample-db-subnets"));
assertEquals("DBSubnetGroupNotFoundFault", missing.getErrorCode());
assertEquals(404, missing.getHttpStatus());
}
@Test
void listDbSubnetGroupsFaultsForMissingName() {
AwsException missing = assertThrows(AwsException.class,
() -> rdsService.listDbSubnetGroups("does-not-exist"));
assertEquals("DBSubnetGroupNotFoundFault", missing.getErrorCode());
assertEquals(404, missing.getHttpStatus());
}
@Test
void listDbSubnetGroupsStillResolvesSyntheticDefault() {
Collection<DbSubnetGroup> groups = rdsService.listDbSubnetGroups("default");
assertEquals(1, groups.size());
assertEquals("default", groups.iterator().next().getDbSubnetGroupName());
}
@Test