From a732e26bc5917f287213ec3c7c1c39e34e67ed91 Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Thu, 20 Aug 2026 08:42:01 -0500 Subject: [PATCH] chore(config): declare every toggleable service in both application.yml files (#2422) Six services (tagging, pipes, configservice, docdb, bedrock-agent-core and bedrock-agent-core-control) had no key in application.yml, and lightsail and cloudhsmv2 had a bare key with no child, so those two bound to nothing. All eight resolved only through the interface @WithDefault, which AGENTS.md does not treat as the source of truth: the YAML defines effective runtime behaviour and is what a user reads and edits. Add the missing keys to src/main/resources/application.yml and to the test config, and add ServiceConfigYamlCoverageTest so the next service cannot drift out. It derives each key with SmallRye's StringUtil.skewer, checking the real binding name rather than a reimplemented guess, and exempts configs with no enabled() toggle such as DuckConfig. The test config keys are for explicitness, not necessity: SmallRye merges both files as config sources per property, with the test file winning per key, so a service absent from the test config would inherit the main value rather than break. Declaring both keeps the two files readable side by side and stops a test-only override from being indistinguishable from an omission. An earlier draft of this message claimed the test file was required because Quarkus replaces rather than merges; that was wrong, and is corrected here. Every value written equals the prior @WithDefault, so runtime behaviour is unchanged. Typed chore rather than fix for that reason. --- src/main/resources/application.yml | 18 +++++ .../config/ServiceConfigYamlCoverageTest.java | 68 +++++++++++++++++++ src/test/resources/application.yml | 16 +++++ 3 files changed, 102 insertions(+) create mode 100644 src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.java diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c806ccf662..b9218f7e65 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -488,6 +488,7 @@ floci: cloudtrail: enabled: true lightsail: + enabled: true cloudcontrol: enabled: true cloudfront: @@ -511,9 +512,26 @@ floci: iotdata: enabled: true cloudhsmv2: + enabled: true rum: enabled: true guardduty: enabled: true emrserverless: enabled: true + tagging: + enabled: true + pipes: + enabled: true + configservice: + enabled: true + docdb: + enabled: true + mock: false + default-image: "mongo:7.0" + bedrock-agent-core: + enabled: true + # invoke-response: '{"output":"yes"}' # Body returned by InvokeAgentRuntime + # validate-runtime-exists: false # true = reject unknown runtime ARNs + bedrock-agent-core-control: + enabled: true diff --git a/src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.java b/src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.java new file mode 100644 index 0000000000..dac89ff9d8 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.java @@ -0,0 +1,68 @@ +package io.github.hectorvent.floci.config; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import io.smallrye.config.common.utils.StringUtil; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Guards the rule that {@code application.yml} — not an interface {@code @WithDefault} — + * is the source of truth for which services run. A service reachable only through its + * fallback default is invisible to anyone reading the config and cannot be toggled from + * the file, which is how six services drifted out of both YAMLs before this test existed. + */ +class ServiceConfigYamlCoverageTest { + + private static final List CONFIGS = List.of( + Path.of("src/main/resources/application.yml"), + Path.of("src/test/resources/application.yml")); + + @Test + void everyToggleableServiceDeclaresEnabledInBothConfigs() throws IOException { + List missing = new ArrayList<>(); + + for (Path config : CONFIGS) { + JsonNode services = new YAMLMapper().readTree(config.toFile()) + .path("floci").path("services"); + + for (Method accessor : EmulatorConfig.ServicesConfig.class.getDeclaredMethods()) { + if (!declaresEnabledToggle(accessor.getReturnType())) { + continue; + } + String key = StringUtil.skewer(accessor.getName()); + if (!services.path(key).path("enabled").isBoolean()) { + missing.add(config + " -> floci.services." + key + ".enabled"); + } + } + } + + assertTrue(missing.isEmpty(), + "Every service config with an enabled() toggle must declare it explicitly in both " + + "application.yml files. Note a bare 'service-name:' key with no child does " + + "not count, since it binds to nothing. Missing: " + missing); + } + + /** + * Config records without an {@code enabled()} toggle (for example {@code DuckConfig}, + * which only carries an image and an optional URL) are not services that can be turned + * off, so they are exempt. + */ + private static boolean declaresEnabledToggle(Class configInterface) { + for (Method method : configInterface.getDeclaredMethods()) { + if (method.getName().equals("enabled") + && method.getParameterCount() == 0 + && (method.getReturnType() == boolean.class || method.getReturnType() == Boolean.class)) { + return true; + } + } + return false; + } +} diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index d36852209c..a13b41277c 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -291,6 +291,7 @@ floci: cloudtrail: enabled: true lightsail: + enabled: true cloudcontrol: enabled: true cloudfront: @@ -314,9 +315,24 @@ floci: iotdata: enabled: true cloudhsmv2: + enabled: true rum: enabled: true guardduty: enabled: true emrserverless: enabled: true + tagging: + enabled: true + configservice: + enabled: true + transcribe: + enabled: true + docdb: + enabled: true + mock: false + default-image: "mongo:7.0" + bedrock-agent-core: + enabled: true + bedrock-agent-core-control: + enabled: true