From 0818e5e2d64215b01d68b11c5b9c4319c1bde549 Mon Sep 17 00:00:00 2001 From: sheldon-nadarajah-sft Date: Sat, 15 Aug 2026 19:06:26 +0200 Subject: [PATCH] fix(appconfig): accept top-level resource ARNs in TagResource/ListTagsForResource (#2279) * fix(appconfig): accept top-level resource ARNs in TagResource/ListTagsForResource AppConfigTagHandler#parseArn hardcoded the assumption that every AppConfig resource ARN nests under application/... - true for environment and configurationprofile, but AWS documents deploymentstrategy, extension, and extensionassociation as top-level, taggable resources (see e.g. the Tags property on AWS::AppConfig::DeploymentStrategy/Extension/ExtensionAssociation). A deploymentstrategy/{id} ARN has parts[0] == "deploymentstrategy", not "application", so it fell through to the 400 at the end of parseArn. Adds a TOP_LEVEL_TYPES set for the three non-nested taggable types and checks it before the application/ branch. Tag storage for these types remains a no-op (same existing precedent as environment/configurationprofile) - this fixes the ARN-shape rejection, not tag persistence for new resource types. Verified real AWS support for all three via CloudFormation's own resource docs before scoping the fix, since a shared ARN-parsing helper is an easy place to fix one AWS-compatibility gap while introducing another (e.g. hostedconfigurationversion, which the existing parts.length==6 branch already over-accepts despite AWS not supporting tagging it at all - left untouched here as a separate, pre-existing issue, out of scope for this fix). * docs(appconfig): clarify no-op-tag javadoc, rename a misleadingly-named test Review feedback on #2279 (Copilot): - The class javadoc singled out hostedconfigurationversion as an example of something AWS doesn't support tagging for, but the existing parts.length==6 branch already accepts (and no-ops) that exact ARN shape - describing current behavior generally instead (application persisted, everything else recognized-but-no-op) rather than calling out one type as if it were rejected. - Renamed tagExtensionAndExtensionAssociationArnsAreAcceptedNotRejected to listTagsForExtensionAndExtensionAssociationArnsIsAcceptedNotRejected - the test only ever calls GET (ListTagsForResource), never POST (TagResource), so the old name would mislead anyone reading a failure. AppConfigIntegrationTest: 25/25 passed. --- .../java/com/floci/test/AppConfigTest.java | 28 ++++++++++++ .../appconfig/AppConfigTagHandler.java | 20 ++++++++- .../appconfig/AppConfigIntegrationTest.java | 44 +++++++++++++++++++ 3 files changed, 90 insertions(+), 2 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 b99df3defc..6081ab3bde 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 @@ -306,4 +306,32 @@ class AppConfigTest { } catch (Exception ignored) {} } } + + @Test + @Order(51) + @DisplayName("TagResource / ListTagsForResource - deploymentstrategy ARN (top-level, not nested under application/)") + void tagDeploymentStrategyViaSdk() { + // deploymentstrategy/extension/extensionassociation ARNs don't nest under application/ + // like every other AppConfig resource tested above - a naive ARN parser can end up + // hardcoding the application/ prefix and rejecting these as invalid, even though AWS + // documents all three as taggable (see e.g. AWS::AppConfig::DeploymentStrategy's Tags + // property). This asserts the SDK call succeeds end-to-end, not just that some ARN shape + // is accepted internally. + String tagStrategyId = appConfig.createDeploymentStrategy(CreateDeploymentStrategyRequest.builder() + .name("tag-roundtrip-strategy") + .deploymentDurationInMinutes(0) + .growthFactor(100f) + .finalBakeTimeInMinutes(0) + .build()).id(); + String arn = "arn:aws:appconfig:us-east-1:000000000000:deploymentstrategy/" + tagStrategyId; + + appConfig.tagResource(TagResourceRequest.builder() + .resourceArn(arn) + .tags(java.util.Map.of("env", "prod")) + .build()); + + ListTagsForResourceResponse listed = appConfig.listTagsForResource( + ListTagsForResourceRequest.builder().resourceArn(arn).build()); + assertThat(listed.tags()).isNotNull(); + } } 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 cbb32a82b3..8ffbcd005d 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 @@ -8,6 +8,7 @@ import jakarta.inject.Inject; import java.util.List; import java.util.Map; +import java.util.Set; /** * {@link TagHandler} implementation for AppConfig. @@ -17,9 +18,14 @@ import java.util.Map; *
  • {@code arn:aws:appconfig:::application/} *
  • {@code arn:aws:appconfig:::application//environment/} *
  • {@code arn:aws:appconfig:::application//configurationprofile/} + *
  • {@code arn:aws:appconfig:::deploymentstrategy/} + *
  • {@code arn:aws:appconfig:::extension/} + *
  • {@code arn:aws:appconfig:::extensionassociation/} * - * Only application-level tags are stored; environment and configurationprofile tag calls - * are accepted (no-op) to satisfy Terraform provider reads. + * Only application-level tags are actually stored; every other recognized ARN shape above is + * accepted (not rejected with a 400) but the tag call itself is a no-op - this satisfies callers + * (e.g. Terraform's AWS provider) that read tags back after a write without erroring on a resource + * type Floci doesn't yet persist tags for. */ @ApplicationScoped public class AppConfigTagHandler implements TagHandler { @@ -68,6 +74,13 @@ public class AppConfigTagHandler implements TagHandler { private record ResourceRef(String type, String id) {} + // The AppConfig resource types AWS documents as taggable that are NOT nested under + // application/... (see e.g. the Tags property on AWS::AppConfig::DeploymentStrategy, + // AWS::AppConfig::Extension, and AWS::AppConfig::ExtensionAssociation) - every other + // taggable type (application, environment, configurationprofile) already nests under + // application/ and is handled by the branch below. + private static final Set TOP_LEVEL_TYPES = Set.of("deploymentstrategy", "extension", "extensionassociation"); + private static ResourceRef parseArn(String arn) { // arn:aws:appconfig::: String resource; @@ -77,6 +90,9 @@ public class AppConfigTagHandler implements TagHandler { throw new AwsException("BadRequestException", "Invalid resource ARN: " + arn, 400); } String[] parts = resource.split("/"); + if (parts.length == 2 && TOP_LEVEL_TYPES.contains(parts[0])) { + return new ResourceRef(parts[0], parts[1]); + } if (parts.length >= 2 && "application".equals(parts[0])) { // application/ if (parts.length == 2) return new ResourceRef("application", parts[1]); 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 ee6c3d4f2c..e5d90f7d5f 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 @@ -317,7 +317,51 @@ class AppConfigIntegrationTest { .body("Tags", anEmptyMap()); } + // ──────────── Tags on top-level (non-application-nested) resource ARNs ──────────── + // deploymentstrategy/extension/extensionassociation are real, taggable AppConfig resource + // types per the API - unlike environment/deployment above, their ARNs don't nest under + // application/..., so they need their own top-level branch in AppConfigTagHandler#parseArn. + // Regression coverage for that ARN-shape acceptance; no tag storage exists for these types + // yet (same no-op precedent as environment/deployment above), so only 200-not-400 is asserted. + @Test @Order(22) + void listTagsForDeploymentStrategyArnIsAcceptedNotRejected() { + String arn = "arn:aws:appconfig:us-east-1:000000000000:deploymentstrategy/" + strategyId; + given() + .when().get("/tags/" + arn) + .then() + .statusCode(200) + .body("Tags", anEmptyMap()); + } + + @Test @Order(23) + void tagDeploymentStrategyArnIsAcceptedNotRejected() { + String arn = "arn:aws:appconfig:us-east-1:000000000000:deploymentstrategy/" + strategyId; + given() + .contentType(ContentType.JSON) + .body("{\"Tags\": {\"env\": \"local\"}}") + .when().post("/tags/" + arn) + .then() + .statusCode(204); + } + + @Test @Order(24) + void listTagsForExtensionAndExtensionAssociationArnsIsAcceptedNotRejected() { + String extensionArn = "arn:aws:appconfig:us-east-1:000000000000:extension/some-extension-id"; + String associationArn = "arn:aws:appconfig:us-east-1:000000000000:extensionassociation/some-association-id"; + given() + .when().get("/tags/" + extensionArn) + .then() + .statusCode(200) + .body("Tags", anEmptyMap()); + given() + .when().get("/tags/" + associationArn) + .then() + .statusCode(200) + .body("Tags", anEmptyMap()); + } + + @Test @Order(25) void emptyConfigurationReturnsEmptyPayload() { emptyAppId = given() .contentType(ContentType.JSON)