Swagger docs (timeout, pagination) + oracle key validation + pool exhaustion monitoring - #481
Merged
nonsobethel0-dev merged 4 commits intoAug 28, 2026
Conversation
Found while working on other issues in this repo — the project did not compile on main: - policy.service.ts referenced StatusEventsService without importing it - error-response.dto.ts used an invalid object key (400_bad, a numeric literal immediately followed by an identifier is not valid JS/TS) - webhooks.service.ts / webhooks.controller.ts / webhooks.module.ts imported PrismaService/PrismaModule via a relative path one directory too shallow (../prisma/... instead of ../../prisma/...) - package-lock.json was out of sync with package.json (missing OpenTelemetry and compression entries), so npm ci failed outright
…ashield-Protocol#471) The health check already reported pool active/idle/waiting counts (Parashield-Protocol#444) but never flagged exhaustion — operators had to interpret raw numbers themselves and the health endpoint stayed "ok" even as the pool filled up. - Compare active connections against the configured pool size (DATABASE_CONNECTION_LIMIT, default 10 — same default PrismaService applies) and compute a utilization percentage - Mark the database check degraded once utilization meets or exceeds DB_POOL_EXHAUSTION_WARN_PERCENT (default 90%), consistent with how keeper balance and replication lag thresholds already work - Extend DatabasePoolDto with max/utilizationPercent/exhausted Also fixes health.controller.spec.ts's mock HealthController construction, which was missing the required REDIS_CLIENT argument and the checkRpcConnectivity() method on the Stellar mock (both added in earlier commits after this spec was written), so every test in the file was failing before any of my changes.
…-Protocol#473) Oracle keys were never validated before use: - GET /oracle/reading?key= and GET /oracle/latest/:key accepted any string, letting a malformed key fall through to a DB lookup that just resolves as a generic 404 instead of a clear "this was never a valid oracle key" 400 - POST /oracle/rainfall and GET /oracle/flight take lat/lng/year/month and flight/date as raw, unvalidated query params (unlike the DTO-backed POST /oracle/fetch/* endpoints) — an unparsable value silently became NaN and built a garbage oracle key/upstream request instead of failing loudly Adds: - oracle-key-format.ts: shared isValidOracleKeyFormat(), recognizing the three formats OracleService ever writes (rainfall/temperature with lat/lng bounds, flight) - OracleKeyValidationMiddleware, registered on GET /oracle/reading and GET /oracle/latest/:key, rejecting a malformed key with 400 before it reaches the controller - Bounds/format checks in getRainfall and getFlight, mirroring the validation OracleFeedRequestDto already applies to the POST endpoints
…arashield-Protocol#467, Parashield-Protocol#472) Request timeout behavior (Parashield-Protocol#467) and pagination parameters (Parashield-Protocol#472) were both applied consistently across the API but never written down anywhere a caller could find them: - New "Request Timeouts" section in the Swagger description: the 30s application-level + socket-level timeout, the 408 response, and that it deliberately does NOT use the standard error envelope (it's written directly by request-timeout middleware before the request reaches route handling, unlike every other documented error response) - New "Pagination" section: page/limit defaults and clamping, the { success, data, total, page, limit } envelope, and which endpoints use it vs. the ?stream=true NDJSON alternative Also brings claims.controller.ts's page/limit @apiquery descriptions (GET /claims, GET /claims/history/:wallet) up to the same level of detail policy.controller.ts's already had (default values, the 100 max, examples) instead of the bare "Page number" / "Items per page" they had.
|
@bbjiggy 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! 🚀 |
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
Closes #467, Closes #471, Closes #472, Closes #473
GET /health: compares active connections against the configured pool size and flags the database check degraded once utilization crosses a configurable threshold (default 90%), instead of only exposing raw pool counts.claims.controller.ts's@ApiQuerydocs up to the same detail levelpolicy.controller.tsalready had.GET /oracle/readingandGET /oracle/latest/:keythat rejects a malformed key with 400 before it reaches the service layer, plus bounds/format validation onPOST /oracle/rainfallandGET /oracle/flight, which previously took raw, unvalidated query params.Also includes one prerequisite commit fixing pre-existing build-breaking bugs found while working on these (missing import, an invalid object key, wrong relative import paths in the webhooks module, and an out-of-sync
package-lock.json) — the project did not compile onmainbefore this.Test plan
npx tsc --noEmit— no new errors introduced (remaining errors are pre-existing and unrelated:auth.guards.spec.ts,claims.worker.ts/policy.controller.ts's paginated-products typing,rate-limit-headers.ts,policy.service.spec.ts)npx jest src/health src/oracle src/claims— all tests in files touched by this PR pass; new tests added for pool exhaustion, oracle key format validation, and the new query-param validationmainthat no previously-passing suite regressed