You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
profiles.test.ts fixture silently discards seeded values, failing 3 tests on main #464
createTestUserProfile in packages/supabase/functions/api/__tests__/routes/profiles.test.ts (~line 23) is broken, and silently so.
It calls admin.auth.admin.createUser(...), then inserts into core.users with id: userId. But a trigger already creates that core.users row on auth signup, so the insert always fails with:
duplicate key value violates unique constraint "users_pkey"
The helper never checks .error, so the failure is invisible and the seeded values — display_name: "Test User", bio, headline: "Software Engineer", years_of_experience: 5 — are never written. The trigger-created row has display_name set to the username instead.
Impact
Three tests assert on those values and fail on main:
GET /v1/profiles/:username - returns public user profile
GET /v1/profiles/:username - includes user skills
GET /v1/profiles/:username - includes user certifications
They look like route bugs and are not. This cost real time to diagnose while working on #441 — a new test asserting the same seeded fields failed for the same reason, and had to be rewritten to assert response shape instead.
Reproduce
cd packages/supabase && deno test --allow-all --no-check --config=functions/api/deno.json functions/api/__tests__/routes/profiles.test.ts
To see the swallowed error directly, log .error from the core.users insert in the helper.
Fix
Change the insert to an upsert (or update the trigger-created row), and check and throw on error so a future breakage is loud rather than silent. Then confirm the three tests above pass.
Out of scope
The same file's organization and employer fixtures fail because core.organizations and core.employers are missing from the local schema cache — 10 further failures, separate root cause, worth its own issue unless investigation shows otherwise.
The fixture bug is one wider than reported. The core.profile insert fails identically (profile_pkey), so location was never seeded either. Both writes are now error-checked upserts.
The three tests do not pass from the fixture fix alone. Repairing it moved test 1's failure from display_name to location and left tests 2 and 3 failing on three separate route defects — a skills embed with no backing FK, a certifications embed pointing at core.certifications when the FK targets data.certifications, and reads of core.profile / core.user_skills / core.user_certifications with a client that holds no grant on them. GET /v1/profiles/:username had been returning empty skills, empty certifications and a null location to every anonymous caller. All three are fixed in the same PR.
The out-of-scope note is inaccurate. The 10 organization/employer failures are not a schema-cache problem: core.organizations exists and the route selects five columns it does not have, while core.employers does not exist at all. Filed as #482 (needs-design — the fix needs a call on whether employers is real).
Also filed #481: eight core.* tables grant SELECT to authenticated but not service_role, which is why the route reads catalogs with the caller's client rather than the service client.
Activity
thinkclay commentedon Jul 30, 2026
Fixed in #479.
Two corrections from working it:
The fixture bug is one wider than reported. The
core.profileinsert fails identically (profile_pkey), solocationwas never seeded either. Both writes are now error-checked upserts.The three tests do not pass from the fixture fix alone. Repairing it moved test 1's failure from
display_nametolocationand left tests 2 and 3 failing on three separate route defects — askillsembed with no backing FK, acertificationsembed pointing atcore.certificationswhen the FK targetsdata.certifications, and reads ofcore.profile/core.user_skills/core.user_certificationswith a client that holds no grant on them.GET /v1/profiles/:usernamehad been returning empty skills, empty certifications and a null location to every anonymous caller. All three are fixed in the same PR.The out-of-scope note is inaccurate. The 10 organization/employer failures are not a schema-cache problem:
core.organizationsexists and the route selects five columns it does not have, whilecore.employersdoes not exist at all. Filed as #482 (needs-design— the fix needs a call on whetheremployersis real).Also filed #481: eight
core.*tables grant SELECT toauthenticatedbut notservice_role, which is why the route reads catalogs with the caller's client rather than the service client.fix(db): grant service_role the eight tables it could not read, and s…
fix(db): grant service_role the eight tables it could not read, and s…