mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(appconfig): add DeleteConfigurationProfile/DeleteHostedConfigurationVersion/ListDeploymentStrategies/DeleteDeploymentStrategy (#2280)
* fix(appconfig): add DeleteConfigurationProfile/DeleteHostedConfigurationVersion/ListDeploymentStrategies/DeleteDeploymentStrategy
These four operations had no route at all, so a request fell through
to S3's generic path-style catch-all (GET/DELETE /{bucket}[/{key}])
and returned a misleading NoSuchBucket 404 instead of a real AppConfig
response - confirmed via both raw HTTP and the real AWS SDK for Java.
Adds the missing routes + AppConfigService methods, mirroring existing
precedent (DeleteConfigurationProfile/DeleteHostedConfigurationVersion/
DeleteDeploymentStrategy follow DeleteApplication's idempotent-delete
convention - no upfront existence check; ListDeploymentStrategies
includes the three predefined strategies alongside custom ones,
verified against the API reference's own sample response).
DeleteDeploymentStrategy's real path is /deployementstrategies/{id}
(extra "e" - a genuine, documented quirk in AWS's own API model; every
other deployment-strategy operation correctly uses
/deploymentstrategies). Confirmed against the API reference and
reproduced against the real SDK, which sends the misspelled path
literally - matched it rather than "fixing" it, since wire-protocol
fidelity to what AWS actually does is the point.
Regenerated docs/services/appconfig.md's Supported Operations list
(hand-maintained for REST controllers - not yet covered by
tools/docs/regen_action_docs.py, confirmed via services.yaml's own
Phase-1 scope comment).
Tests: AppConfigIntegrationTest (+4), compatibility-tests/sdk-test-java
AppConfigTest (+1, covering all four operations via the real SDK).
Ran locally (JDK 25):
AppConfigIntegrationTest (unit): 29/29 passed
AppConfigTest (SDK compat, live): 16/16 passed
* fix(appconfig): scope profile deletion to its application, reject deleting predefined strategies
Review feedback on #2280 (Copilot + Greptile, both independently):
- deleteConfigurationProfile ignored appId entirely and deleted by the
bare, globally-keyed profileId - a caller could delete another
application's profile just by guessing/reusing its ID, since
sibling reads (getConfigurationProfile) already enforce this
ownership check but the new delete route didn't. Now rejects with
the same ResourceNotFoundException as a mismatched get; a profileId
that doesn't exist anywhere is still an idempotent no-op, matching
deleteApplication's existing convention - only an existing-but-
wrongly-scoped one is rejected.
- Same method also now cascades the delete to that profile's hosted
configuration versions - they aren't independently addressable
outside a profile's lifecycle, so leaving them in versionStore after
the profile was "deleted" let a caller keep fetching versions for a
profile that supposedly no longer exists.
- deleteDeploymentStrategy silently reported success (204) for a
predefined strategy (e.g. AppConfig.AllAtOnce) without doing
anything, since builtins were never in strategyStore in the first
place - the strategy would still exist and still show up in every
subsequent Get/List call despite the "successful" delete. Now
rejects with BadRequestException.
Also applied this project's own established cleanup-logging
convention (System.err.println on a best-effort catch, matching
several other compatibility-tests/sdk-test-java files) to the one new
try/finally block flagged by Greptile, rather than swallowing the
exception silently.
Tests: 2 new AppConfigIntegrationTest cases (cross-application delete
rejected + original untouched, predefined-strategy delete rejected +
still resolvable) and 2 new SDK compatibility tests using the real
AWS SDK for Java v2's exception types.
AppConfigIntegrationTest: 31/31 passed
AppConfigTest (SDK compat, live): 18/18 passed
* chore: retrigger CI
This commit is contained in:
1 parent
c163a8678c
commit
be625023eb
5 files changed
+335
No files matched your search
@@ -118,6 +118,13 @@ public class AppConfigController {
|
||||
return Response.ok(root).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/applications/{appId}/configurationprofiles/{profileId}")
|
||||
public Response deleteConfigurationProfile(@PathParam("appId") String appId, @PathParam("profileId") String profileId) {
|
||||
service.deleteConfigurationProfile(appId, profileId);
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Hosted Configuration Version ────────────────────────────
|
||||
|
||||
@GET
|
||||
@@ -152,6 +159,15 @@ public class AppConfigController {
|
||||
return versionResponse(version, 200);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/applications/{appId}/configurationprofiles/{profileId}/hostedconfigurationversions/{versionNumber}")
|
||||
public Response deleteHostedConfigurationVersion(@PathParam("appId") String appId,
|
||||
@PathParam("profileId") String profileId,
|
||||
@PathParam("versionNumber") int versionNumber) {
|
||||
service.deleteHostedConfigurationVersion(appId, profileId, versionNumber);
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
private Response versionResponse(HostedConfigurationVersion v, int status) {
|
||||
Response.ResponseBuilder rb = Response.status(status).entity(v.getContent());
|
||||
rb.header("Application-Id", v.getApplicationId());
|
||||
@@ -179,6 +195,28 @@ public class AppConfigController {
|
||||
return Response.ok(service.getDeploymentStrategy(id)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/deploymentstrategies")
|
||||
public Response listDeploymentStrategies() {
|
||||
List<DeploymentStrategy> items = service.listDeploymentStrategies();
|
||||
ObjectNode root = objectMapper.createObjectNode();
|
||||
ArrayNode arr = root.putArray("Items");
|
||||
items.forEach(arr::addPOJO);
|
||||
return Response.ok(root).build();
|
||||
}
|
||||
|
||||
// AWS's own API model spells this path "deployementstrategies" (extra "e") - every other
|
||||
// deployment-strategy operation correctly uses "deploymentstrategies". Confirmed against the
|
||||
// real API reference (both the Request Syntax and Sample Request sections agree) and
|
||||
// reproduced against the real AWS SDK for Java v2, which sends the misspelled path literally -
|
||||
// matching that typo, not "fixing" it, is what real AWS wire-protocol compatibility means here.
|
||||
@DELETE
|
||||
@Path("/deployementstrategies/{id}")
|
||||
public Response deleteDeploymentStrategy(@PathParam("id") String id) {
|
||||
service.deleteDeploymentStrategy(id);
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Deployment ────────────────────────────
|
||||
|
||||
@POST
|
||||
|
||||
@@ -111,6 +111,28 @@ public class AppConfigService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void deleteConfigurationProfile(String appId, String profileId) {
|
||||
// Unlike deleteApplication (a single, unscoped ID), a profile is nested under an
|
||||
// application - a mismatched appId must not be able to delete another application's
|
||||
// profile just because its bare profileId is guessed/known. A profileId that doesn't
|
||||
// exist at all is still an idempotent no-op, matching deleteApplication's convention;
|
||||
// only an existing-but-wrongly-scoped one is rejected.
|
||||
profileStore.get(profileId).ifPresent(profile -> {
|
||||
if (!profile.getApplicationId().equals(appId)) {
|
||||
throw new AwsException("ResourceNotFoundException", "Configuration profile not found in this application", 404);
|
||||
}
|
||||
});
|
||||
// A hosted configuration version isn't independently addressable outside its profile's
|
||||
// lifecycle - cascade the delete so a caller can't still fetch versions for a profile
|
||||
// that's supposedly gone.
|
||||
String versionPrefix = appId + "::" + profileId + "::";
|
||||
versionStore.keys().stream()
|
||||
.filter(k -> k.startsWith(versionPrefix))
|
||||
.toList()
|
||||
.forEach(versionStore::delete);
|
||||
profileStore.delete(profileId);
|
||||
}
|
||||
|
||||
// ──────────────────────────── Hosted Configuration Version ────────────────────────────
|
||||
|
||||
public HostedConfigurationVersion createHostedConfigurationVersion(String appId, String profileId, byte[] content, String contentType, String description) {
|
||||
@@ -153,6 +175,10 @@ public class AppConfigService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void deleteHostedConfigurationVersion(String appId, String profileId, int versionNumber) {
|
||||
versionStore.delete(appId + "::" + profileId + "::" + versionNumber);
|
||||
}
|
||||
|
||||
// ──────────────────────────── Deployment Strategy ────────────────────────────
|
||||
|
||||
public DeploymentStrategy createDeploymentStrategy(Map<String, Object> request) {
|
||||
@@ -176,6 +202,30 @@ public class AppConfigService {
|
||||
return strategyStore.get(id).orElseThrow(() -> new AwsException("ResourceNotFoundException", "Deployment strategy not found", 404));
|
||||
}
|
||||
|
||||
public List<DeploymentStrategy> listDeploymentStrategies() {
|
||||
// Real AWS's ListDeploymentStrategies includes the predefined strategies alongside
|
||||
// custom ones (confirmed via the API reference's own sample response) - the predefined
|
||||
// ones aren't in strategyStore at all (see getDeploymentStrategy's builtinStrategy check
|
||||
// above), so they need to be added explicitly here too.
|
||||
List<DeploymentStrategy> result = new ArrayList<>(List.of(
|
||||
builtinStrategy("AppConfig.AllAtOnce"),
|
||||
builtinStrategy("AppConfig.Linear50PercentEvery30Seconds"),
|
||||
builtinStrategy("AppConfig.Canary10Percent20Minutes")));
|
||||
result.addAll(strategyStore.scan(k -> true));
|
||||
return result;
|
||||
}
|
||||
|
||||
public void deleteDeploymentStrategy(String id) {
|
||||
// Predefined strategies aren't real stored resources (see builtinStrategy above) -
|
||||
// silently no-op'ing here would report success for a delete that did nothing, and the
|
||||
// "deleted" strategy would still show up in every subsequent Get/List call.
|
||||
if (builtinStrategy(id) != null) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"Predefined deployment strategy " + id + " cannot be deleted.", 400);
|
||||
}
|
||||
strategyStore.delete(id);
|
||||
}
|
||||
|
||||
private static DeploymentStrategy builtinStrategy(String id) {
|
||||
return switch (id) {
|
||||
case "AppConfig.AllAtOnce" -> {
|
||||
|
||||
Reference in new issue
Block a user