What Happened
Sparki’s web app had a latent bug: if the server environment was misconfigured with a URL likesparki.tools instead of https://sparki.tools, the entire login system and API would silently crash on startup. Users would hit a blank or broken app with no useful error message.
This is the kind of mistake that happens during a hosting migration, a staging environment setup, or when a new engineer sets up their .env file from memory rather than from the template.
What Was Fixed
A small validation helper (ensureValidUrl) now sits between environment variables and the clients that consume them. If an invalid URL is detected, it logs a clear warning and falls back to a known-safe default rather than crashing. The fix was applied to all seven places in the codebase that construct URLs from environment variables.
What Was Built: Smoke Test Suite
A smoke test suite was added — 25 automated tests that run on every code push and verify:- The URL validator behaves correctly for all edge cases (missing protocol, empty string, undefined)
- The API client and auth client initialize without errors
- Every critical page in the dashboard renders without entering an error state
Business Impact
- Deployment confidence: Engineers can ship knowing that a misconfigured URL will be caught before it affects users.
- Faster incident detection: If this bug ever regressed, it would be caught in CI in seconds rather than discovered by a user.
- Onboarding safety net: New engineers or new environments with malformed
.envfiles get an explicit warning, not a cryptic crash.
Action Items
- Audit
.env.examplein all other Sparki services (api-engine, auth-shield) for similar bare-hostname patterns - Add the
ensureValidUrlpattern to the sharedcommon-ts-libso other frontend apps can use it - Consider a startup health-check endpoint that validates all required env vars on boot