fix: replace non-null assertions with explicit handling - #1171
Merged
nanaf6203-bit merged 2 commits intoSep 1, 2026
Conversation
Remove all non-null assertion operators in src/ so null paths surface typed errors or defaults instead of crashing with a generic TypeError. - cache/notifications/duplicate-detection: fall back to a fresh Set or existing map entry instead of asserting presence after a guarded get - properties: validate lat/lng upfront and use narrowed locals for the radius bounding-box math - auth: guard TOTP/backup codes before verifying 2FA - property-comparison/neighborhoods: throw NotFoundException when a looked-up entity is missing - versioning: only set the Sunset header when a date resolves - specs: type prisma mocks fully so requestLog!/supportTicket!/ digestPreference!/info! assertions are no longer needed
|
@shadrackmanfred Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
nanaf6203-bit
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces every non-null assertion operator (
!) insrc/with explicit handling so that missing values surface as typed, contextual errors (or safe defaults) instead of genericTypeErrors at runtime. Count of real assertion sites insrc/: 45 → 0.What changed
cache/notifications/duplicate-detectionmap.get(x)!.add(y)after a guardedhas()checkSet/ existing map entry, then re-insert (?? new Set(), or reuse the entry when present)propertiesdto.lat!/dto.lng!inside the radius bounding-box mathBadRequestException('Both lat and lng must be provided together'); math uses narrowed localsauthdata.totpCode!/data.backupCode!in 2FA loginUnauthorizedExceptionbefore verificationproperty-comparisonproperties.find(...)!NotFoundExceptionif a property is missingneighborhoodsneighborhood!.metadataNotFoundExceptionafterfindUniqueversioningtoHttpDate(meta.sunsetDate)!Sunsetheader set only when a date resolvesprisma.requestLog!,info!,supportTicket!,digestPreference!MockPrisma-style interfaces;stats?.xassertions instead of!No behavior change for valid inputs — the same exceptions (
NotFoundException/BadRequestException/UnauthorizedException) that existed are preserved, and the API error contract is unchanged.Verification
npx tsc --noEmit— no new errors vsmain(baseline carries 2 pre-existing errors in untouched files:sessions.service.tsandversion-header.interceptor.spec.ts)npm test— all affected suites pass; the only failing suite (version-header.interceptor.spec.ts:111) fails identically onmain!matches insrc/after this change are all inside string literals or commentsCloses #1083