mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
BedrockAgentCoreControlController, GatewayController, GatewayRuleController, IdentityController, MemoryController, ResourcePolicyController, and ToolsController each carried their own byte-for-byte identical copy of error(Exception, String) (AwsException maps to a structured JSON body with an X-Amzn-Errortype header, anything else falls back to a 400 ValidationException), the single most duplicated area CPD found across src/main. Three of them (Control, Gateway, Memory) also carried an identical stringMap(JsonNode) JSON-object-to-map helper, and four (Control, Gateway, Identity, Memory) carried an identical text(JsonNode, String) field-extraction helper found along the way. Extracted all three into a new package-private BedrockAgentCoreControllerSupport. Each controller keeps its own private error/stringMap/text methods as one-line delegations (error still takes the caller's own LOG so log lines keep attributing to the right controller), so no call site elsewhere in any of the seven files needed to change. putInstant deliberately stays out: it's duplicated too, but it's two genuinely different behaviors (ISO-8601 strings for runtimes and gateways, epoch seconds for workload identities and memories) wearing the same method name, not one shared behavior. Merging it would risk conflating the two. While here, also finished what #3556 started delegating: BedrockAgentCoreMemoryController had its own separate awsError(AwsException) doing the exact same thing as error(), added for the new event endpoints. Routed those four call sites through the existing error() method instead and removed the duplicate. Also fixed BedrockAgentCoreMemoryController's import block, which had non-java/java.util imports interleaved into the jakarta.ws.rs group. No behavior change. Removing AwsErrorResponse/AwsException/HashMap imports that became unused after the extraction where applicable. Full bedrockagentcorecontrol and bedrockagentcore test suites (95 tests) pass unchanged. Three of the seven controllers (GatewayRule, ResourcePolicy, Tools) have no existing test coverage at all; manually verified the delegated error() renders identical ValidationException/ResourceNotFoundException responses on ResourcePolicyController before removing the verification test, since adding permanent coverage for previously-untested controllers is a separate concern from this issue's scope.