You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replace 45 non-null assertions with explicit handling: crash-on-null paths are hidden in compiled code #1083
Replace 45 non-null assertions with explicit handling: crash-on-null paths are hidden in compiled code
Labels / Complexity: bug · Medium Complexity — Medium
Problem
The codebase contains 45 non-null assertion operators (!) on values that are not statically guaranteed present (verified with a repository-wide grep). Each one is a runtime undefined/null dereference waiting to happen: the type system is told "trust me", and when the value is absent at runtime the failure is a generic TypeError instead of a typed error, often inside a request handler with no context.
The failures are silent until they crash. Because ! suppresses the check at compile time, the first signal is a runtime exception in production, not a type error in CI.
The assertion sites are the risk map. They cluster where the code already doubts its data (conditional access, optional fields, map lookups) — exactly the paths that deserve explicit if/throw handling with typed errors.
Why this is architecturally hard
Each site needs a decision. The fix is not a mechanical ! → ? swap: every site must decide between a typed NotFoundException/BadRequestException, a default value, or a genuine invariant (in which case the assertion should be a checked helper, not a bare !).
The error contract must stay consistent. The repo uses NestJS exceptions; replacing crash sites with the right exception type is part of the fix, and the API error shape must not change for callers.
Slicing is required. 45 sites span many modules; the migration should land per module so each PR is reviewable and the remaining count is tracked.
Acceptance criteria
Every non-null assertion is replaced with explicit handling: a typed exception, a default, or a documented checked invariant.
The repository-wide ! count on non-typed values is zero (or the remaining sites are documented invariants with a checked helper).
npx tsc --noEmit and npm test pass; no behavior change for valid inputs.
Out of scope
The @ts-nocheck migrations (#890 slices); changing API error messages.
Getting started
Repository-wide: grep -rn "!" src --include=*.ts to enumerate sites
src/common/ — where a checked invariant helper would live
Commands: npx tsc --noEmit, npm test.
Good first files to read: one module's service with the most assertion sites, then src/common/.
@shadrackmanfred has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
Hi Maintainer! I'm a senior developer with experience building high-quality, production-ready software. I'd love to take on this issue and deliver a clean, well-tested solution that aligns with the project's standards. Please assign it to me—I'm ready to get started and contribute effectively.
Congratulations, @shadrackmanfred! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.
🧑💻 @shadrackmanfred: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
Resolved on branch fix/type-safety-and-admin-tests (commit 1f932bf): all runtime non-null assertions in src/ replaced with typed exceptions, defaults, or narrowed conditions (runtime ! count 45 → 0). Verified: tsc --noEmit clean, 71 suites / 515 unit tests pass. PR is pending push from a token with write access.
Activity
kaizercodes commentedon Aug 26, 2026
@kaizercodes has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @kaizercodes to this issue.
Teejay2696 commentedon Aug 26, 2026
@Teejay2696 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Teejay2696 to this issue.
codewithzubair07 commentedon Aug 26, 2026
@codewithzubair07 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @codewithzubair07 to this issue.
shadrackmanfred commentedon Aug 26, 2026
@shadrackmanfred has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @shadrackmanfred to this issue.
drips-wave commentedon Aug 26, 2026
Congratulations, @shadrackmanfred! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.
🧑💻 @shadrackmanfred: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
shadrackmanfred commentedon Aug 28, 2026
Resolved on branch
fix/type-safety-and-admin-tests(commit 1f932bf): all runtime non-null assertions in src/ replaced with typed exceptions, defaults, or narrowed conditions (runtime!count 45 → 0). Verified: tsc --noEmit clean, 71 suites / 515 unit tests pass. PR is pending push from a token with write access.shadrackmanfred commentedon Aug 29, 2026
test
shadrackmanfred commentedon Sep 1, 2026
Addressed by #1171.