From 7fa2a28c627bcbe93a0b1bf6ea769691bc2bc8c3 Mon Sep 17 00:00:00 2001 From: Kenshin Okinaka Date: Tue, 5 May 2026 10:18:53 +0900 Subject: [PATCH] fix(appconfig): use capital "Tags" body key matching AWS SDK wire format (#704) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AppConfigTagHandler inherited the default tagsBodyKey() = "tags" (lowercase), so SharedTagsController parsed and serialised the tag payload with the lowercase key. The AWS spec for AppConfig TagResource and ListTagsForResource is capital "Tags" with a map body, which is what AWS SDK clients send and expect — so SDK calls to appConfig.tagResource(...) silently dropped tags and listing came back empty. Override tagsBodyKey() on AppConfigTagHandler to return "Tags". The other axes (POST method, map body, lowercase tagKeys query) already match the defaults so no further override is needed. AppConfigIntegrationTest is updated to send capital "Tags" bodies and assert capital "Tags" response keys, matching the AWS SDK wire format. AppConfigTest (SDK compatibility) now exercises a tagResource → listTagsForResource → untagResource round-trip via AppConfigClient to lock in the wire format end-to-end. --- .../java/com/floci/test/AppConfigTest.java | 40 +++++++++++++++++++ .../appconfig/AppConfigTagHandler.java | 5 +++ .../appconfig/AppConfigIntegrationTest.java | 16 ++++---- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java index b26a18fbb2..b99df3defc 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java @@ -266,4 +266,44 @@ class AppConfigTest { // The RestAssured internal test sees "" (raw HTTP header value). assertThat(response.versionLabel()).isNull(); } + + @Test + @Order(50) + @DisplayName("TagResource / ListTagsForResource - SDK round-trip") + void tagAndListViaSdk() { + // Reproducer for the wire-format mismatch that previously made AWS SDK callers + // silently get an empty tag set: SDK serializes as {"Tags": {...}} (capital), + // floci must accept and echo back that exact shape. + String tagAppId = appConfig.createApplication(CreateApplicationRequest.builder() + .name("tag-roundtrip-app") + .build()).id(); + String arn = "arn:aws:appconfig:us-east-1:000000000000:application/" + tagAppId; + try { + appConfig.tagResource(TagResourceRequest.builder() + .resourceArn(arn) + .tags(java.util.Map.of("env", "prod", "owner", "Alice")) + .build()); + + ListTagsForResourceResponse listed = appConfig.listTagsForResource( + ListTagsForResourceRequest.builder().resourceArn(arn).build()); + assertThat(listed.tags()) + .containsEntry("env", "prod") + .containsEntry("owner", "Alice"); + + appConfig.untagResource(UntagResourceRequest.builder() + .resourceArn(arn) + .tagKeys("env") + .build()); + + assertThat(appConfig.listTagsForResource( + ListTagsForResourceRequest.builder().resourceArn(arn).build()).tags()) + .doesNotContainKey("env") + .containsEntry("owner", "Alice"); + } finally { + try { + appConfig.deleteApplication(DeleteApplicationRequest.builder() + .applicationId(tagAppId).build()); + } catch (Exception ignored) {} + } + } } diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigTagHandler.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigTagHandler.java index fd689f7ae4..cbb32a82b3 100644 --- a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigTagHandler.java +++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigTagHandler.java @@ -36,6 +36,11 @@ public class AppConfigTagHandler implements TagHandler { return "appconfig"; } + @Override + public String tagsBodyKey() { + return "Tags"; + } + @Override public Map listTags(String region, String arn) { ResourceRef ref = parseArn(arn); diff --git a/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java index 1fce3ddc7a..d653716e90 100644 --- a/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java @@ -233,7 +233,7 @@ class AppConfigIntegrationTest { .when().get("/tags/" + arn) .then() .statusCode(200) - .body("tags", anEmptyMap()); + .body("Tags", anEmptyMap()); } @Test @Order(15) @@ -241,7 +241,7 @@ class AppConfigIntegrationTest { String arn = "arn:aws:appconfig:us-east-1:000000000000:application/" + appId; given() .contentType(ContentType.JSON) - .body("{\"tags\": {\"env\": \"local\", \"team\": \"platform\"}}") + .body("{\"Tags\": {\"env\": \"local\", \"team\": \"platform\"}}") .when().post("/tags/" + arn) .then() .statusCode(204); @@ -254,8 +254,8 @@ class AppConfigIntegrationTest { .when().get("/tags/" + arn) .then() .statusCode(200) - .body("tags.env", equalTo("local")) - .body("tags.team", equalTo("platform")); + .body("Tags.env", equalTo("local")) + .body("Tags.team", equalTo("platform")); } @Test @Order(17) @@ -274,8 +274,8 @@ class AppConfigIntegrationTest { .when().get("/tags/" + arn) .then() .statusCode(200) - .body("tags", not(hasKey("env"))) - .body("tags.team", equalTo("platform")); + .body("Tags", not(hasKey("env"))) + .body("Tags.team", equalTo("platform")); } // ──────────────────────────── Tags on non-application resources (no-op) ──────────────────────────── @@ -287,7 +287,7 @@ class AppConfigIntegrationTest { .when().get("/tags/" + arn) .then() .statusCode(200) - .body("tags", anEmptyMap()); + .body("Tags", anEmptyMap()); } @Test @Order(20) @@ -297,7 +297,7 @@ class AppConfigIntegrationTest { .when().get("/tags/" + arn) .then() .statusCode(200) - .body("tags", anEmptyMap()); + .body("Tags", anEmptyMap()); } @Test @Order(21)