Skip to content

Phase 4.3: enable backend strict mode and close surfaced diagnostics#143

Merged
rendall merged 9 commits intomasterfrom
phase-4_3
Mar 7, 2026
Merged

Phase 4.3: enable backend strict mode and close surfaced diagnostics#143
rendall merged 9 commits intomasterfrom
phase-4_3

Conversation

@rendall
Copy link
Owner

@rendall rendall commented Mar 6, 2026

Summary

Implements Phase 4.3 (docs/plans/phase-4_3-checklist.md) by enabling backend/functions TypeScript strict mode and remediating surfaced strictness diagnostics with minimal behavior change.

What changed

  • Enabled "strict": true in tsconfig.netlify.functions.json.
  • Added strict-safe error helpers in src/lib/backend-utilities.ts:
    • isApiError
    • toApiError
    • toErrorBody
  • Updated function handlers to narrow caught unknown errors before returning API responses:
    • src/functions/auth.ts
    • src/functions/comment.ts
    • src/functions/gauth.ts
    • src/functions/topic.ts
    • src/functions/verify.ts
  • Updated src/lib/MongodbService.ts strict hotspots:
    • _client / _db optional initialization
    • unknown catch-body normalization for admin-facing 500 responses
    • verifyGET catch narrowing for TokenExpiredError
  • Added backend test coverage for new error helpers in src/tests/backend/utilities.test.ts.
  • Updated planning docs:
    • Marked all Phase 4.3 checklist items complete.
    • Recorded Phase 4.3 completion + Phase 4.4 gate decision.
    • Added Phase 4.4 checklist document.

Checklist status

Phase 4.3 checklist items C01-C06 are complete in docs/plans/phase-4_3-checklist.md.
No TODO(phase-04.4) suppressions were added.

Validation

Executed successfully:

  • yarn run typecheck
  • MONGOMS_DOWNLOAD_URL="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-6.0.14.tgz" TZ="UTC" yarn test:backend
  • TZ="UTC" yarn test:frontend
  • yarn run ci:local

Notes:

  • Existing lint warning remains in src/tests/backend/MongodbService.test.ts for an unused variable; no lint errors.
  • Existing webpack warnings from mongodb bundling are unchanged and ci:local passes.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables TypeScript strict mode for Netlify backend/functions compilation and applies strict-safe error handling/narrowing across backend runtime paths, plus adds targeted tests and updates Phase 04 planning documentation.

Changes:

  • Turned on "strict": true for backend/functions TypeScript builds.
  • Introduced backend error helpers (isApiError, toApiError, toErrorBody) and updated handlers/service code to safely normalize unknown catch values.
  • Added backend tests for the new error helpers and updated Phase 04 planning/checklist docs (including archiving Phase 4.2 checklist).

Reviewed changes

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

Show a summary per file
File Description
tsconfig.netlify.functions.json Enables TypeScript strict mode for backend/functions.
src/lib/backend-utilities.ts Adds strict-safe error helper utilities used by handlers/services.
src/tests/backend/utilities.test.ts Adds unit tests covering the new backend error helpers.
src/lib/MongodbService.ts Adjusts strict hotspots (optional init fields; admin-safe error body normalization; TokenExpiredError narrowing).
src/functions/auth.ts Normalizes caught unknown via toApiError before responding.
src/functions/comment.ts Normalizes caught unknown via toApiError before responding.
src/functions/gauth.ts Normalizes caught unknown via toApiError before responding.
src/functions/topic.ts Normalizes caught unknown via toApiError before responding.
src/functions/verify.ts Normalizes caught unknown via toApiError before responding (uses 400 fallback).
docs/plans/phase-4_3-checklist.md Adds Phase 4.3 checklist document (strict baseline).
docs/plans/phase-4_4-checklist.md Adds Phase 4.4 checklist document (env contract + runtime clarity).
docs/plans/phase-4_2_1-ci-local-parity-checklist.md Removes Phase 4.2.1 checklist document.
docs/plans/phase-04-type-safety-and-env-handling.md Updates Phase 04 plan status/scope and records phase completion + gate notes.
docs/archive/phase-4_2-checklist.md Archives Phase 4.2 checklist document.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c6158d424

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rendall rendall merged commit 4b3ce2d into master Mar 7, 2026
7 checks passed
@rendall rendall deleted the phase-4_3 branch March 7, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants