Skip to content

fix(exports): replace stub health probes with real dependency checks … - #1665

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
Thadd102:fix/1574-exports-health-probes
Nov 26, 2026
Merged

greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
Thadd102:fix/1574-exports-health-probes

Conversation

@Thadd102

Copy link
Copy Markdown
Contributor

Closes #1574

Replaces the four stub health probes in GET /api/exports/health (src/routes/exports/health.ts) with real database, object-storage, worker-queue, and notification API checks with timeouts, secret sanitization, and failure-path tests.

Changes

  • Database probe (probeDatabase): Executes SELECT 1 against pool from src/db.ts with a timeout guard; reports degraded when latency exceeds DB_DEGRADED_THRESHOLD_MS (1000 ms) and down on error or timeout.
  • Object storage probe (probeStorage): Returns ok with detail: 'exports disabled' when config.exports.enabled is false. When enabled, validates config.exports.endpoint via validateStorageEndpoint, issues a HEAD request to the configured bucket with an AbortController timeout, reports degraded on non-auth 4xx, and down on 401/403, 5xx, validation failure, network error, or timeout.
  • Worker queue probe (probeQueue): Exposes getWorkerStatus() on ReportExporterWorker and ScheduledExportsWorker (state, intervalMs, lastTickAt, lastTickAgeMs, lastError). Returns ok (exports disabled) when exports are disabled; when enabled, reports down if no workers are registered, a worker is stopped, or its last tick is stale, and degraded if a running worker has recorded an error.
  • Notification API probe (probeNotificationApi): Performs an HTTP GET to the new optional EXPORTS_NOTIFICATION_HEALTH_URL env var using an AbortController timeout; skipped as ok with detail when unset.
  • Sanitization & resilience: Added sanitizeDetail() to redact URL credentials, bearer/basic tokens, sensitive query parameters, and config.exports.signingSecret from detail strings. Hardened withTimeout() to catch synchronous throws without leaking timers.
  • Config & docs: Added EXPORTS_NOTIFICATION_HEALTH_URL to src/config/execution-env.ts, src/config/core-settings.ts, and .env.example.
  • Tests: Expanded src/routes/exports/health.test.ts with success and failure-path tests for all four probes (rejections, timeouts with jest.useFakeTimers(), non-2xx responses, slow-but-ok DB, invalid endpoint config, synchronous throws, live worker status integration, and secret redaction).

Acceptance Criteria Checklist

  • No TODO remains in src/routes/exports/health.ts
  • Failing or hanging dependencies report down with sanitized detail within the timeout, and overall status is derived via deriveOverallStatus
  • Disabled/unconfigured exports do not cause the endpoint to report failure
  • Response shape (overall, dependencies, checkedAt, correlationId) is unchanged
  • Every probe remains individually injectable via ProbeRegistry

Testing

  • npm test -- src/routes/exports/health.test.ts (71/71 passing)
  • npm test -- src/services/reportExporter.test.ts src/services/scheduledExports.test.ts (20/20 passing)
  • npx eslint src/routes/exports/health.ts src/routes/exports/health.test.ts src/services/reportExporter.ts src/services/scheduledExports.ts src/config/execution-env.ts src/config/core-settings.ts (0 errors)
  • npm run typecheck (0 errors in touched files)

@drips-wave

drips-wave Bot commented Nov 25, 2026

Copy link
Copy Markdown

@Thadd102 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

@greatest0fallt1me
greatest0fallt1me merged commit 1e0e1b0 into CalloraOrg:main Nov 26, 2026
1 check passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Thanks @Thadd102! Merged. 🎉

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.

Replace the stub probes in src/routes/exports/health.ts with real database, storage, queue and notification checks

2 participants