Skip to content

chore: enabling strictNullChecks in back-end sources - #3338

Open
ericleponner wants to merge 38 commits into
mainfrom
3316_strictnullcheck_in_backend
Open

chore: enabling strictNullChecks in back-end sources#3338
ericleponner wants to merge 38 commits into
mainfrom
3316_strictnullcheck_in_backend

Conversation

@ericleponner

@ericleponner ericleponner commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description:

Changes below enable strict-null-checks and strictBindingCallApply flags in back-end tsconfig.json.

Related issue(s):

Fixes #3316

@ericleponner ericleponner self-assigned this Aug 25, 2026
@swirlds-automation

swirlds-automation commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (5cd0f09) to head (1e36ef6).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3338      +/-   ##
==========================================
- Coverage   99.98%   99.92%   -0.06%     
==========================================
  Files         213      213              
  Lines        6699     6725      +26     
  Branches     1209     1229      +20     
==========================================
+ Hits         6698     6720      +22     
- Misses          1        5       +4     
Files with missing lines Coverage Δ
back-end/apps/api/src/auth/auth.service.ts 100.00% <100.00%> (ø)
...k-end/apps/api/src/auth/strategies/jwt.strategy.ts 100.00% <ø> (ø)
...d/apps/api/src/auth/strategies/otp-jwt.strategy.ts 100.00% <ø> (ø)
...s/api/src/auth/strategies/otp-verified.strategy.ts 100.00% <ø> (ø)
...-end/apps/api/src/guards/frontend-version.guard.ts 100.00% <100.00%> (ø)
...ack-end/apps/api/src/guards/jwt-blacklist.guard.ts 100.00% <100.00%> (ø)
...on-preferences/notification-preferences.service.ts 100.00% <100.00%> (ø)
...fication-receiver/notification-receiver.service.ts 98.71% <100.00%> (-1.29%) ⬇️
...pi/src/transactions/approvers/approvers.service.ts 100.00% <100.00%> (ø)
...ransactions/dto/update-transaction-approver.dto.ts 100.00% <100.00%> (ø)
... and 15 more

... and 1 file with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ericleponner
ericleponner force-pushed the 3316_strictnullcheck_in_backend branch 4 times, most recently from e2c1862 to 416d2c2 Compare August 25, 2026 17:15
@ericleponner
ericleponner marked this pull request as ready for review August 25, 2026 17:46
@ericleponner
ericleponner requested a review from a team as a code owner August 25, 2026 17:46
@ericleponner
ericleponner requested a review from svienot August 25, 2026 17:46
@jbair06
jbair06 requested a lite review from Copilot August 25, 2026 22:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ericleponner
ericleponner force-pushed the 3316_strictnullcheck_in_backend branch from 416d2c2 to 8d9321b Compare August 26, 2026 15:20
@steven-sheehy steven-sheehy added this to the v0.38.0 milestone Aug 26, 2026
@steven-sheehy steven-sheehy added the Feature Enhancement Enhancing an existing feature driven by business requirements. Typically backwards compatible. label Aug 26, 2026
@steven-sheehy
steven-sheehy marked this pull request as draft August 26, 2026 15:24
@svienot
svienot requested a lite review from Copilot August 26, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 105 out of 105 changed files in this pull request and generated 2 comments.

Suppressed comments (6)

back-end/apps/notifications/src/receiver/receiver.service.ts:1

  • transaction.creatorKeyis accessed as non-null, but the function comment says a deleted creator key will not be included (i.e., it can be null/undefined). This can throw at runtime. Use optional chaining (and filter out missing creatorId) or explicitly throw if a creator key is required for this flow, and adjust downstream uses ofcreatorId!` accordingly.
    back-end/libs/common/src/transaction-signature/account-cache.service.ts:1
  • encodedKey is a bytea/Buffer | null field, but this code writes [] when accountData.key is null. This will store the wrong type and may fail at runtime or serialize incorrectly. Use null (or undefined if you intend to omit updating the column) instead of an empty array.
    back-end/libs/common/src/execute/execute.service.ts:1
  • Using undefined in a TypeORM .set() commonly means “do not update this column”. If transactionStatusCode is null and you intend to clear statusCode, this will leave the previous DB value untouched (stale status code). Prefer setting statusCode to null when you want to clear it, or build the .set() object conditionally to match the intended semantics.
    back-end/apps/api/src/users/users.service.ts:1
  • When reactivating a soft-deleted user, deletedAt should be explicitly cleared. Setting it to undefined typically results in “no update” (keeping the user deleted) depending on how updateUser() persists. Use deletedAt: null to reliably undelete the user (and keep tests aligned with the actual persistence semantics).
    back-end/libs/common/src/transaction-signature/transaction-signature.service.ts:1
  • New error message is missing punctuation and uses inconsistent quoting, which makes it harder to search/standardize in logs. Consider using a consistent message format (e.g., No fee payer account id.) and (optionally) a domain-specific error type if callers need to distinguish configuration/data errors from internal errors.
    back-end/apps/api/src/auth/auth.service.ts:125
  • Falling back to '' when OTP_SECRET is not configured can create a predictable OTP secret, which may allow OTP verification to succeed under a misconfiguration. Instead, reject verification when the secret is missing (e.g., throw UnauthorizedException or a configuration error) rather than verifying against an empty secret.
    const secret = this.getOtpSecret(user.email) ?? '';

    const { valid } = await otplib.verify({
      token,
      secret,

Comment on lines 296 to 302
const k = key(item);
if (!map.has(k)) {
map.set(k, []);
if (k) {
if (!map.has(k)) {
map.set(k, []);
}
map.get(k)!.push(item);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

case TransactionNodeCollection.HISTORY: {
statusFilter = statusFilter?.length ? statusFilter : TRANSACTION_STATUS_COLLECTIONS.HISTORY;
transactionTypeFilter = transactionTypeFilter?.length ? transactionTypeFilter : null;
transactionTypeFilter = transactionTypeFilter.length ? transactionTypeFilter : [];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type of transactionTypeFilter is TransactionType[] : so optional chaining is useless.

@ericleponner
ericleponner force-pushed the 3316_strictnullcheck_in_backend branch 5 times, most recently from fa41973 to c81aeba Compare August 28, 2026 18:27
@ericleponner
ericleponner marked this pull request as ready for review August 28, 2026 18:29
@ericleponner
ericleponner marked this pull request as draft August 28, 2026 19:40
@ericleponner
ericleponner marked this pull request as ready for review August 31, 2026 12:37
@ericleponner
ericleponner force-pushed the 3316_strictnullcheck_in_backend branch 3 times, most recently from ee93024 to 7032c49 Compare August 31, 2026 17:01
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
…rsByTransactionId().

Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
… transactionRepoGroup.findOne() returns null.

Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
…ionStatusUpdate().

Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
@ericleponner
ericleponner force-pushed the 3316_strictnullcheck_in_backend branch from 5a6b0d6 to 1e36ef6 Compare September 1, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Feature Enhancement Enhancing an existing feature driven by business requirements. Typically backwards compatible.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enabling strictNullChecks in back-end/tsconfig.json

5 participants