From c9c93ac5653ddcfe81796ce00bc0b763bea0c4eb Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Mon, 20 Apr 2026 09:11:47 +0200 Subject: [PATCH] fix(alerting): declare ClickHouseSearchIndex bean as concrete type Production crashlooped on startup: ExchangeMatchEvaluator autowires the concrete ClickHouseSearchIndex (for countExecutionsForAlerting, which lives only on the concrete class, not the SearchIndex interface), but StorageBeanConfig declared the bean with interface return type SearchIndex. Spring matches autowire candidates by declared bean type, not by runtime instance class, so the concrete-typed autowire failed with: Parameter 0 of constructor in ExchangeMatchEvaluator required a bean of type 'ClickHouseSearchIndex' that could not be found. ClickHouseLogStore's bean is already declared with the concrete return type (line 171), which is why LogPatternEvaluator autowires fine. All alerting ITs passed pre-merge because AbstractPostgresIT replaces the clickHouseSearchIndex bean with @MockBean(name=...) whose declared type IS the concrete ClickHouseSearchIndex. The mock masked the prod bug. Follow-up: remove @MockBean(name="clickHouseSearchIndex") from AbstractPostgresIT so the real bean graph is exercised by alerting ITs (and add a SpringContextSmokeIT that loads the context with no mocks). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../com/cameleer/server/app/config/StorageBeanConfig.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cameleer-server-app/src/main/java/com/cameleer/server/app/config/StorageBeanConfig.java b/cameleer-server-app/src/main/java/com/cameleer/server/app/config/StorageBeanConfig.java index 775bbc7b..57fbc9be 100644 --- a/cameleer-server-app/src/main/java/com/cameleer/server/app/config/StorageBeanConfig.java +++ b/cameleer-server-app/src/main/java/com/cameleer/server/app/config/StorageBeanConfig.java @@ -123,9 +123,14 @@ public class StorageBeanConfig { } @Bean - public SearchIndex clickHouseSearchIndex( + public ClickHouseSearchIndex clickHouseSearchIndex( TenantProperties tenantProperties, @Qualifier("clickHouseJdbcTemplate") JdbcTemplate clickHouseJdbc) { + // Return type is the concrete class so Spring exposes the bean under both + // SearchIndex (for SearchIndexer) AND ClickHouseSearchIndex (for ExchangeMatchEvaluator, + // which calls countExecutionsForAlerting — a method that exists only on the concrete type). + // Declaring the return as the interface hides the concrete methods from autowire + // matching and crashloops the app on startup. return new ClickHouseSearchIndex(tenantProperties.getId(), clickHouseJdbc); } -- 2.49.1