fix(test): repair main Test Suite (pg_net + service + seed + retire validator)#359
Conversation
Migration 20260408033928 created pg_net with no target schema. On a fresh database (CI `supabase start` replay), where pg_net is not pre-provisioned, `CREATE EXTENSION IF NOT EXISTS pg_net` fails with 3F000 "no schema has been selected to create in" — breaking the Schema Drift Check and Test Suite on every migration PR. Pin it to the extensions schema, matching the convention already used in 20260409232440. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Greptile SummaryThis PR repairs the main branch test suite, which had 30 failing tests blocking all queued PRs, by addressing five distinct failure clusters across CI configuration, test infrastructure, and the migration.
Confidence Score: 4/5Safe to merge for CI unblocking; the net.http_post / search_path mismatch in the migration function (flagged in a previous review) may silently break the cron worker on any instance where the April migration was already applied. The test infrastructure changes are well-reasoned and the workspace-seeding and otel session-binding fixes are correct. The one outstanding concern — net.http_post referenced under search_path = public, vault, net while pg_net now lives in the extensions schema — was flagged in the prior review and is not addressed here. That cron-worker regression would not surface during pnpm test, making it easy to miss in production. supabase/migrations/20260408033928_add_hub_tables_vectors_pgmq_realtime.sql — the pg_net schema move and the cron function's search_path/net.http_post call need to be reconciled. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[supabase start] -->|pg_net WITH SCHEMA extensions| B[Extensions load correctly]
B --> C[Test Suite: pnpm test]
C --> D[supabase-storage.test.ts]
D -->|beforeEach: truncateAllTables + ensureTestWorkspace| D1[FK constraints satisfied ✓]
C --> E[otel-storage.test.ts]
E -->|storage.ingest payload with otel_session_id| E1[otel_events populated]
E -->|seedSessionWithOtel creates sessions + runs row| E2[DB session UUID returned]
E1 & E2 --> E3[querySessionTimeline / querySessionCost joins runs → otel_events ✓]
C --> F[intelligence-pipeline.test.ts]
F -->|beforeEach drain: pgmq_read_queue vt=0 + archive loop| F1[Stale thought_processing messages cleared]
F1 --> F2[thought insert enqueue assertion isolated ✓]
C --> G[architecture.test.ts]
G -->|branch/handlers.ts added to known-debt list| G1[SupabaseClient constraint passes ✓]
C --> H[validate-pr-description.test.ts]
H -->|File deleted — validator retired| H1[6 tests removed ✓]
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/__tests__/intelligence-pipeline.test.ts:112-122
**Silent errors in queue drain may leave stale messages**
Both the `pgmq_read_queue` call and each `pgmq_archive_queue_message` call discard their `error` fields. If the read RPC fails, `stale` is `null` and the drain silently does nothing, leaving stale messages in the queue and potentially causing the immediately-following assertion tests to flake. Destructure and throw (or at minimum `console.warn`) on non-null error so a drain failure is visible rather than masked.
Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/test-suite-..." | Re-trigger Greptile |
|
|
||
| await storage.ingest(parseLogsPayload(logsPayload, TEST_WORKSPACE_ID)); | ||
|
|
||
| const sessionId = await seedSessionWithOtel('timeline-session'); |
There was a problem hiding this comment.
Static otelSessionId strings make these three tests fragile on repeated runs. The
beforeEach only clears otel_events — it does not truncate sessions or runs. If the runs table has a uniqueness constraint on otel_session_id, or if querySessionTimeline/querySessionCost join through the runs table and pick up stale rows from a previous run, tests can give wrong counts or duplicate-key errors the second time pnpm test is run against the same database. randomUUID() is already imported in this file and used in the "no cost events" test directly below — apply the same pattern here.
| const sessionId = await seedSessionWithOtel('timeline-session'); | |
| const sessionId = await seedSessionWithOtel(randomUUID()); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/otel/__tests__/otel-storage.test.ts
Line: 197
Comment:
Static otelSessionId strings make these three tests fragile on repeated runs. The `beforeEach` only clears `otel_events` — it does not truncate `sessions` or `runs`. If the `runs` table has a uniqueness constraint on `otel_session_id`, or if `querySessionTimeline`/`querySessionCost` join through the runs table and pick up stale rows from a previous run, tests can give wrong counts or duplicate-key errors the second time `pnpm test` is run against the same database. `randomUUID()` is already imported in this file and used in the "no cost events" test directly below — apply the same pattern here.
```suggestion
const sessionId = await seedSessionWithOtel(randomUUID());
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| await storage.ingest(parseLogsPayload(logsPayload, TEST_WORKSPACE_ID)); | ||
|
|
||
| const sessionId = await seedSessionWithOtel('limit-session'); |
There was a problem hiding this comment.
Same static-string issue as the timeline test above — use
randomUUID() for isolation.
| const sessionId = await seedSessionWithOtel('limit-session'); | |
| const sessionId = await seedSessionWithOtel(randomUUID()); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/otel/__tests__/otel-storage.test.ts
Line: 231
Comment:
Same static-string issue as the timeline test above — use `randomUUID()` for isolation.
```suggestion
const sessionId = await seedSessionWithOtel(randomUUID());
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
|
||
| const cost = await storage.querySessionCost(TEST_WORKSPACE_ID, 'cost-session'); | ||
| expect(cost.session_id).toBe('cost-session'); | ||
| const sessionId = await seedSessionWithOtel('cost-session'); |
There was a problem hiding this comment.
Same static-string issue — use
randomUUID() for isolation.
| const sessionId = await seedSessionWithOtel('cost-session'); | |
| const sessionId = await seedSessionWithOtel(randomUUID()); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/otel/__tests__/otel-storage.test.ts
Line: 272
Comment:
Same static-string issue — use `randomUUID()` for isolation.
```suggestion
const sessionId = await seedSessionWithOtel(randomUUID());
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| CREATE EXTENSION IF NOT EXISTS pgmq; | ||
| CREATE EXTENSION IF NOT EXISTS pg_cron; | ||
| CREATE EXTENSION IF NOT EXISTS pg_net; | ||
| CREATE EXTENSION IF NOT EXISTS pg_net WITH SCHEMA extensions; |
There was a problem hiding this comment.
Modifying an applied migration vs. adding a new one
This migration was timestamped April 2026, two months ago. Editing it in place is correct for environments that always reset from scratch (CI, supabase start), but any Supabase instance where this migration was already applied won't receive the WITH SCHEMA extensions fix — it would need a follow-up migration (ALTER EXTENSION pg_net SET SCHEMA extensions). If there is a remote/production instance, the pg_net schema fix won't land there until one is added.
Prompt To Fix With AI
This is a comment left during a code review.
Path: supabase/migrations/20260408033928_add_hub_tables_vectors_pgmq_realtime.sql
Line: 7
Comment:
**Modifying an applied migration vs. adding a new one**
This migration was timestamped April 2026, two months ago. Editing it in place is correct for environments that always reset from scratch (CI, `supabase start`), but any Supabase instance where this migration was already applied won't receive the `WITH SCHEMA extensions` fix — it would need a follow-up migration (`ALTER EXTENSION pg_net SET SCHEMA extensions`). If there is a remote/production instance, the pg_net schema fix won't land there until one is added.
How can I resolve this? If you propose a fix, please make it concise.
Goal
main's required Test Suite check is red from pre-existing breakage (30 failing tests), blocking every queued PR. This branch repairs it.Fixes in this PR
supabase startdies onpg_net3F000pg_net WITH SCHEMA extensionssupabase-storage.test.tsFK violationsensureTestWorkspace()inbeforeEach(matches knowledge test)storage-api+edge-runtimeinsupabase startvalidate-pr-description.test.tsvalidate:pr) per decisionarchitecture.test.tsbranch/handlers.tsas knownSupabaseClientdebtStill under investigation (draft)
otel-storage.test.ts(4) — query failuresbranch-workers.test.ts(1) — signed-tokenintelligence-pipeline.test.ts(1)Notes
.github/(ci.yml + validate-pr.yml deletion) → requires thegovernance-approvedlabel to pass "Prevent Governance Deletions".🤖 Generated with Claude Code