Conversation
There was a problem hiding this comment.
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": truefor backend/functions TypeScript builds. - Introduced backend error helpers (
isApiError,toApiError,toErrorBody) and updated handlers/service code to safely normalizeunknowncatch 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.
There was a problem hiding this comment.
💡 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".
Summary
Implements Phase 4.3 (
docs/plans/phase-4_3-checklist.md) by enabling backend/functions TypeScriptstrictmode and remediating surfaced strictness diagnostics with minimal behavior change.What changed
"strict": trueintsconfig.netlify.functions.json.src/lib/backend-utilities.ts:isApiErrortoApiErrortoErrorBodyunknownerrors before returning API responses:src/functions/auth.tssrc/functions/comment.tssrc/functions/gauth.tssrc/functions/topic.tssrc/functions/verify.tssrc/lib/MongodbService.tsstrict hotspots:_client/_dboptional initializationverifyGETcatch narrowing forTokenExpiredErrorsrc/tests/backend/utilities.test.ts.Checklist status
Phase 4.3 checklist items
C01-C06are complete indocs/plans/phase-4_3-checklist.md.No
TODO(phase-04.4)suppressions were added.Validation
Executed successfully:
yarn run typecheckMONGOMS_DOWNLOAD_URL="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-6.0.14.tgz" TZ="UTC" yarn test:backendTZ="UTC" yarn test:frontendyarn run ci:localNotes:
src/tests/backend/MongodbService.test.tsfor an unused variable; no lint errors.ci:localpasses.