fix(backend): switch to sentry-spring-boot-4:8.41.0 for Spring Boot 4/SF7 compatibility
Some checks failed
CI / Unit & Component Tests (pull_request) Successful in 6m12s
CI / OCR Service Tests (pull_request) Successful in 42s
CI / Backend Unit Tests (pull_request) Failing after 17m13s
CI / fail2ban Regex (pull_request) Successful in 2m37s
CI / Compose Bucket Idempotency (pull_request) Successful in 2m6s
Some checks failed
CI / Unit & Component Tests (pull_request) Successful in 6m12s
CI / OCR Service Tests (pull_request) Successful in 42s
CI / Backend Unit Tests (pull_request) Failing after 17m13s
CI / fail2ban Regex (pull_request) Successful in 2m37s
CI / Compose Bucket Idempotency (pull_request) Successful in 2m6s
sentry-spring-boot-starter-jakarta 8.5.0 does not support Spring Boot 4.0 — it logs an "Incompatible Spring Boot Version" warning and its SentryAutoConfiguration crashes SF7 bean-name generation. sentry-spring-boot-4 (added in 8.21.0) is the dedicated Spring Boot 4 module with a fixed auto-configuration class. - Replace sentry-spring-boot-starter-jakarta:8.5.0 with sentry-spring-boot-4:8.41.0 - Delete SentryConfig.java — workaround no longer needed, auto-config handles init - Remove spring.autoconfigure.exclude from application.yaml + application-test.yaml - Delete SentryConfigTest.java — tested the deleted workaround class - Update ApplicationContextTest: assert Sentry.isEnabled() is false when no DSN set Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,8 +31,8 @@ class ApplicationContextTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void sentry_auto_configuration_is_excluded_from_context() {
|
||||
// SentryAutoConfiguration crashes on Spring Boot 4/SF7 — must stay excluded (see #580)
|
||||
assertThat(ctx.containsBean("sentryAutoConfiguration")).isFalse();
|
||||
void sentry_is_disabled_when_no_dsn_is_configured() {
|
||||
// application-test.yaml has no sentry.dsn — SDK must stay inactive so tests are clean
|
||||
assertThat(io.sentry.Sentry.isEnabled()).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package org.raddatz.familienarchiv.config;
|
||||
|
||||
import io.sentry.Sentry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
class SentryConfigTest {
|
||||
|
||||
@Test
|
||||
void init_does_not_call_sentry_when_dsn_is_blank() {
|
||||
SentryConfig config = new SentryConfig();
|
||||
ReflectionTestUtils.setField(config, "dsn", "");
|
||||
ReflectionTestUtils.setField(config, "environment", "test");
|
||||
ReflectionTestUtils.setField(config, "tracesSampleRate", 1.0);
|
||||
|
||||
try (MockedStatic<Sentry> sentryMock = mockStatic(Sentry.class)) {
|
||||
config.init();
|
||||
sentryMock.verifyNoInteractions();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void init_calls_sentry_init_when_dsn_is_set() {
|
||||
SentryConfig config = new SentryConfig();
|
||||
ReflectionTestUtils.setField(config, "dsn", "https://key@glitchtip.example.com/1");
|
||||
ReflectionTestUtils.setField(config, "environment", "test");
|
||||
ReflectionTestUtils.setField(config, "tracesSampleRate", 0.5);
|
||||
|
||||
try (MockedStatic<Sentry> sentryMock = mockStatic(Sentry.class)) {
|
||||
config.init();
|
||||
sentryMock.verify(() -> Sentry.init(any(Sentry.OptionsConfiguration.class)), times(1));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void init_does_not_call_sentry_when_dsn_is_null() {
|
||||
SentryConfig config = new SentryConfig();
|
||||
ReflectionTestUtils.setField(config, "dsn", null);
|
||||
ReflectionTestUtils.setField(config, "environment", "test");
|
||||
ReflectionTestUtils.setField(config, "tracesSampleRate", 1.0);
|
||||
|
||||
try (MockedStatic<Sentry> sentryMock = mockStatic(Sentry.class)) {
|
||||
config.init();
|
||||
sentryMock.verifyNoInteractions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,6 @@ spring:
|
||||
password: test
|
||||
mail:
|
||||
host: localhost
|
||||
autoconfigure:
|
||||
exclude:
|
||||
# SentryAutoConfiguration fails on Spring Boot 4/Spring Framework 7: Spring cannot generate a
|
||||
# bean name for the triply-nested SentryAutoConfiguration$HubConfiguration$SentrySpanRestClientConfiguration.
|
||||
# Sentry is wired manually via SentryConfig instead. See #580.
|
||||
- io.sentry.spring.boot.jakarta.SentryAutoConfiguration
|
||||
|
||||
# Disable OTel SDK entirely in tests — prevents auto-configuration from loading resource providers
|
||||
# (e.g. AzureAppServiceResourceProvider) that fail against the semconv version used here.
|
||||
|
||||
Reference in New Issue
Block a user