Conversation
f50d514 to
8cd319e
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for capturing Supabase’s sb-request-id header, propagating it through request context, queue jobs/events, and structured logging so downstream operations can be correlated using the Supabase request identifier.
Changes:
- Introduces
requestContext+getSbReqId*helpers to extractsb-request-idand expose it asrequest.sbReqId. - Threads
sbReqIdthrough storage DB context (StorageKnexDB), queue/event payloads, and many logSchema calls (including Logflare mapping torequest_id). - Adds/updates tests across queue, migrations, JWKS, TUS lifecycle, and webhooks to validate propagation.
Reviewed changes
Copilot reviewed 60 out of 60 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/webhooks.test.ts | Adds coverage ensuring reqId (trace) stays distinct from sbReqId in queued webhook payloads. |
| src/test/tenant-jwks.test.ts | Ensures JWKS roll queue payload carries sbReqId. |
| src/test/admin-migrations.test.ts | Ensures admin migrations endpoints pass sbReqId into migration scheduling. |
| src/storage/uploader.ts | Propagates sbReqId into uploader error/event logs. |
| src/storage/storage.ts | Propagates sbReqId into storage logs/events. |
| src/storage/scanner/scanner.ts | Adds sbReqId to scanner event payload/log context. |
| src/storage/object.ts | Adds sbReqId propagation across object operations/events/logging. |
| src/storage/events/pgboss/upgrade-v10.ts | Logs pg-boss upgrade failures with sbReqId. |
| src/storage/events/pgboss/upgrade-v10.test.ts | Tests sbReqId is included in upgrade error logs. |
| src/storage/events/pgboss/move-jobs.ts | Logs move-jobs errors with sbReqId. |
| src/storage/events/pgboss/move-jobs.test.ts | Tests sbReqId presence in move-jobs error logs. |
| src/storage/events/objects/object-admin-delete.ts | Threads sbReqId through admin delete logs (including dispose failures). |
| src/storage/events/objects/object-admin-delete-all-before.ts | Threads sbReqId through admin delete-all-before logs (including dispose failures). |
| src/storage/events/objects/backup-object.ts | Threads sbReqId through backup/delete logs (including dispose failures). |
| src/storage/events/migrations/run-migrations.ts | Adds sbReqId to migrations event logs. |
| src/storage/events/migrations/run-migrations.test.ts | Extends tests asserting sbReqId is logged on success/failure. |
| src/storage/events/migrations/reset-migrations.ts | Threads sbReqId into reset logs and follow-up job scheduling. |
| src/storage/events/migrations/reset-migrations.test.ts | Adds tests for sbReqId propagation in reset flow. |
| src/storage/events/lifecycle/webhook.ts | Extends webhook payload typing + logs to include sbReqId. |
| src/storage/events/lifecycle/bucket-deleted.ts | Passes sbReqId into bucket-deleted handling context. |
| src/storage/events/jwks/jwks-roll-url-signing-key.ts | Includes sbReqId in JWKS roll logs. |
| src/storage/events/jwks/jwks-roll-url-signing-key.test.ts | Adds tests for sbReqId in JWKS roll success/failure logs. |
| src/storage/events/jwks/jwks-create-signing-secret.ts | Includes sbReqId in JWKS create logs. |
| src/storage/events/base-event.ts | Threads reqId/sbReqId into storage creation + webhook send error log context. |
| src/storage/database/knex.ts | Adds sbReqId to StorageKnexDB state. |
| src/storage/database/adapter.ts | Extends DB interfaces/options to include sbReqId. |
| src/internal/queue/queue.ts | Extracts sbReqId from job payload and includes it in queue-task error logs. |
| src/internal/queue/queue.test.ts | Adds coverage for sbReqId extraction (top-level and nested webhook payload). |
| src/internal/queue/index.ts | Re-exports queue constants (incl. SYSTEM_TENANT). |
| src/internal/queue/event.ts | Adds sbReqId to BasePayload and queue error logs. |
| src/internal/queue/constants.ts | Introduces SYSTEM_TENANT placeholder for fleet/system queue jobs. |
| src/internal/monitoring/request-context.ts | Adds helpers to extract sbReqId from headers and job payloads. |
| src/internal/monitoring/request-context.test.ts | Tests header/payload extraction behavior. |
| src/internal/monitoring/logger.ts | Extends log schema types + allowlists sb-request-id header. |
| src/internal/monitoring/logger.test.ts | Adds test ensuring Logflare transport hooks are wired when enabled. |
| src/internal/monitoring/logflare.ts | Maps sbReqId into Logflare request_id. |
| src/internal/monitoring/logflare.test.ts | Adds unit tests for Logflare payload shaping and error handler. |
| src/internal/monitoring/index.ts | Re-exports request-context helpers. |
| src/internal/database/migrations/migrate.ts | Threads sbReqId through fleet migration/reset scheduler + lock logging. |
| src/internal/database/migrations/migrate.test.ts | Adds tests for sbReqId propagation into fleet scheduler logs/jobs. |
| src/internal/auth/jwks/generator.ts | Threads sbReqId through JWKS generator logs and jobs. |
| src/http/routes/tus/lifecycle.ts | Uses logSchema for TUS lifecycle warnings/errors and includes sbReqId. |
| src/http/routes/tus/lifecycle.test.ts | Adds tests for sbReqId in TUS lifecycle logging paths. |
| src/http/routes/tus/index.ts | Threads sbReqId into raw TUS upload context; exports publicRoutes for testing. |
| src/http/routes/tus/index.test.ts | Tests sbReqId is present on public TUS route raw upload context. |
| src/http/routes/admin/queue.ts | Sends sbReqId + SYSTEM_TENANT for fleet queue maintenance tasks. |
| src/http/routes/admin/queue.test.ts | Adds tests asserting sbReqId is passed into scheduled queue tasks. |
| src/http/routes/admin/objects.ts | Converts orphan stream error logging to logSchema with sbReqId. |
| src/http/routes/admin/migrations.ts | Passes sbReqId into fleet migrate/reset helpers. |
| src/http/routes/admin/jwks.ts | Passes sbReqId into JWKS roll and generator; updates generator call signature. |
| src/http/plugins/tracing.ts | Adds sbReqId to tracing mode error logs. |
| src/http/plugins/storage.ts | Adds sbReqId to StorageKnexDB construction for request-scoped storage. |
| src/http/plugins/request-context.ts | New plugin extracting sbReqId from headers onto the Fastify request. |
| src/http/plugins/request-context.test.ts | Tests request-context behavior with/without header. |
| src/http/plugins/log-request.ts | Uses request logger as sink for otel/log metadata errors and includes sbReqId in request logs. |
| src/http/plugins/log-request.test.ts | Adds test ensuring sbReqId appears in emitted request log lines. |
| src/http/plugins/index.ts | Exports the new requestContext plugin. |
| src/http/plugins/db.ts | Adds sbReqId to DB dispose error logs. |
| src/app.ts | Registers requestContext plugin in the main app. |
| src/admin-app.ts | Registers requestContext plugin in the admin app. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 24802340028Coverage increased (+1.3%) to 71.253%Details
Uncovered Changes
Coverage Regressions6 previously-covered lines in 4 files lost coverage.
Coverage Stats💛 - Coveralls |
8cd319e to
5def5ea
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 60 out of 60 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5def5ea to
2c67d9d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 67 out of 67 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Also propagate the existing `reqId` where missed. Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
2c67d9d to
7fee908
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 67 out of 67 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What kind of change does this PR introduce?
feat
What is the current behavior?
Supabase specific request id isn't supported.
What is the new behavior?
Supabase specific request id
sb-request-idheader is read and propagated downstream and serialized asrequest_idat top level for logflare.Additional context
Increased coverage a bit when applicable.
Refactored a few places not using log schema.
Also propagate the existing
reqIdwhere missed.Fixed any usage in touched files except db to keep scope smaller, related to #922