Implement the following plan: Fix: JDBC URL Startup Validation Context The backend fails…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
Implement the following plan:
Fix: JDBC URL Startup Validation
Context
The backend fails at startup with a cryptic HikariCP stacktrace:
codeCaused by: java.lang.RuntimeException: Driver org.mariadb.jdbc.Driver claims to not accept jdbcUrl, 3306/secmanThe
DB_CONNECTenvironment variable is set to an incomplete value (3306/secman) instead of the required full JDBC URL (jdbc:mariadb://hostname:3306/secman). The default inapplication.ymlis correct, but whenDB_CONNECTis explicitly set to a malformed value, HikariCP fails with this unhelpful error.Goal: Add a startup validation check that detects a malformed
DB_CONNECTURL and fails fast with a clear, actionable error message — before HikariCP's cryptic stacktrace.Change
Add
DatasourceUrlValidator.ktFile:
src/backendng/src/main/kotlin/com/secman/config/DatasourceUrlValidator.kt(new)Create a
@Contextsingleton that validates the datasource URL during eager bean initialization, before HikariCP attempts to create its connection pool.- Use
@Contextannotation for eager initialization (runs before lazy beans like DataSource) - Use
@Value("${datasources.default.url}")to read the resolved URL - In
@PostConstruct, validate the URL starts withjdbc:mariadb:// - Throw
IllegalStateExceptionwith a clear message explaining the expected format and thatDB_CONNECTneeds to be fixed - Use
@Requires(notEnv = ["test"])to skip in test environments (Testcontainers provides its own URL)
Why
@Context+@PostConstruct: The DataSource bean is created during bean resolution (triggered by Flyway), which happens beforeApplicationStartupEvent.@Contextforces eager creation of our validator during the bean initialization phase, giving us the best chance to run first. Even in the rare case where HikariCP fails before our validator runs, the validator's error message will still appear in logs, making the root cause clear.Follows existing pattern:
DefaultAdminBootstrapper.kt,SystemUseCaseInitializer.kt - Use
Assistant
★ Insight ─────────────────────────────────────Why@Contextover@Singleton? Micronaut's@Contextscope forces eager bean initialization during startup, unlike@Singletonwhich is lazy by default. This is critical here because we need to validate the JDBC URL before HikariCP tries to use it. The@PostConstructlifecycle hook runs right after the bean is created, giving us a clean validation point.Why
@Requires(notEnv = ["test"])? Integration tests use Testcontainers, which dynamically generates JDBC URLs (likejdbc:tc:mariadb://...). Skipping this validator in test environments avoids false positives.─────────────────────────────────────────────────Let me create the validator.
Assistant
Now let me verify it compiles.
Assistant
Now let me run the full build as required by the project principles.
Assistant
Build passes cleanly. The implementation is complete.
★ Insight ─────────────────────────────────────Bean initialization order matters: In Micronaut,@Context-scoped beans are created eagerly during application startup, while regular@Singletonbeans are created lazily on first access. By using@Context, we ensure our validator runs during the early bean initialization phase — ideally before HikariCP's DataSource bean is resolved. Even if HikariCP happens to initialize first in some edge cases, our validator's error message will still appear in the logs, making the root cause immediately clear.The
@Requires(notEnv = ["test"])guard: This is a common Micronaut pattern to conditionally disable beans. Testcontainers generates dynamic JDBC URLs (often withjdbc:tc:prefix), so the validator would produce false positives in test environments.─────────────────────────────────────────────────Summary: Created
DatasourceUrlValidator.ktin the config package. WhenDB_CONNECTis set to something like3306/secmaninstead ofjdbc:mariadb://hostname:3306/secman, the app now fails fast with a prominent log banner and a clear — no more cryptic HikariCP driver errors.- User
please carefully analyze and add the AWS Account ID if existing also in the table , last element in line
- User
[Image: image/png]
- User
[Image: source: REDACTED 2026-03-05 at 08.10.21.png]
Assistant
Let me first read the existing plan file, then explore the relevant code.
Assistant
This is a different task. Let me explore the Products Overview page — both the frontend component and the backend API that serves the systems-per-product data.
Assistant
Excellent exploration results. The data flow is clear —
cloudAccountIdexists on theAssetentity but is simply not mapped through to the DTO or displayed in the UI. Let me read the key files to confirm the exact edit locations.Assistant
Now let me check the table rendering in the frontend component and the export logic in the service.
Assistant
I now have a complete picture of all the edit locations. Let me write the plan.
Assistant
★ Insight ─────────────────────────────────────Full-stack column addition pattern: Adding a column to a table in this stack follows a clean 4-layer path: JPA Entity (already has the field) → DTO (add field) → Service (map it) → Frontend (display it). ThecloudAccountIdis already persisted and indexed (idx_asset_cloud_account) — we're just threading it through the presentation layers. The Excel export is a separate code path that also needs updating, which is easy to miss.─────────────────────────────────────────────────The plan covers all 4 files across the full stack. No schema changes needed —
cloudAccountIdalready exists on theAssetentity and is populated during imports.- User
[Request interrupted by user for tool use]