Skip to content

Select only needed columns; drain in-flight webhook deliveries on shutdown - #796

Merged
nonsobethel0-dev merged 1 commit into
Parashield-Protocol:mainfrom
gboigwe:fix/757-758-777-778-batch
Oct 19, 2026
Merged

nonsobethel0-dev merged 1 commit into
Parashield-Protocol:mainfrom
gboigwe:fix/757-758-777-778-batch

Conversation

@gboigwe

@gboigwe gboigwe commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • [perf] Prisma queries do not use select to limit returned columns #757 — getActiveProducts (public products list) and getPolicy (every policy detail view + every SSE heartbeat re-check) now use Prisma select for only the columns their response mapping actually reads, instead of fetching the full row. These are the two highest-traffic queries in policy.service.ts; I did not audit every Prisma call in the file for this PR (see note below).

  • [bug] Graceful shutdown does not drain in-flight webhook deliveries #777 — Every webhook delivery is fired without being awaited by its caller (deliberately, per the existing #493 comment, so delivery never delays the request). That meant nothing was tracking them, so SIGTERM could abort a delivery mid-retry. WebhooksService now tracks in-flight deliveries in a Set and drains them in onApplicationShutdown, bounded by a configurable WEBHOOK_SHUTDOWN_DRAIN_TIMEOUT_MS (default 10s). Deliveries still pending at the timeout are logged with enough detail to replay manually — not auto-requeued, since there's no persistent delivery-log table to resume them from yet (would be a separate, larger change).

  • [bug] PolicyController does not filter sensitive fields in list responses #758 — Investigated thoroughly: every PolicyController list/detail endpoint already returns a manually-constructed, narrow object (PolicySummary/ProductSummary), not a raw Prisma row — getUserPolicies, searchPolicies, getActiveProducts, getPolicy, the CSV export, and all admin product mutations all map through this. The Prisma schema also has no "internal notes" or "audit data" columns on Policy/Product as the issue describes. I could not reproduce a current leak; closing via this PR per the usual workflow, but flagging in case I've missed a path — happy to reopen with specifics.

  • [bug] Claims evidence upload does not enforce per-file size limit #778 — Investigated: there is no actual file-upload endpoint anywhere in this codebase yet (no multer, no @UploadedFile/@UploadedFiles, nothing in claims.controller.ts/SubmitClaimDto). evidence-validation.ts already has correct per-file size + magic-byte validation (MAX_EVIDENCE_FILE_SIZE), it's just never called from anywhere — it's dead code waiting on an upload endpoint that doesn't exist yet. Building that endpoint from scratch is a real feature, not a fix to an existing one, so out of scope here; closing via this PR, but it may be worth re-scoping as a feature request instead.

Separately, unrelated to these 4 issues

While reading policy.service.ts I noticed it has two methods both named findAll (one around line 749, one around line 1196, identical signatures) — this should be a TypeScript duplicate-function-implementation compile error. Not touching it here since it's outside scope, but flagging for visibility.

Test plan

No npm install was run for this change (environment constraint) — please run npm run lint, npm run typecheck, and npm test as part of review. I did not add new tests for #757 (query results are unchanged in shape, only columns fetched) or write a benchmark; both are listed acceptance criteria I did not exercise.

Closes #757
Closes #758
Closes #777
Closes #778

…tdown

- Parashield-Protocol#757: getActiveProducts and getPolicy now select only the columns
  their mapping actually reads instead of fetching full rows — these
  are the two highest-traffic queries (public product list, every
  policy detail view + SSE heartbeat).
- Parashield-Protocol#777: WebhooksService now tracks in-flight deliveries and drains
  them in onApplicationShutdown with a configurable timeout
  (WEBHOOK_SHUTDOWN_DRAIN_TIMEOUT_MS, default 10s) instead of letting
  SIGTERM abort a delivery mid-retry. Deliveries still pending at the
  timeout are logged, not auto-requeued — there is no persistent
  delivery log to resume them from yet.
- Parashield-Protocol#758 and Parashield-Protocol#778: investigated, no code change — see PR description.

Closes Parashield-Protocol#757
Closes Parashield-Protocol#758
Closes Parashield-Protocol#777
Closes Parashield-Protocol#778
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@gboigwe 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! 🚀

Learn more about application limits

@nonsobethel0-dev
nonsobethel0-dev merged commit 8f94ee8 into Parashield-Protocol:main Oct 19, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants