Repository navigation
Description
Eight core.* tables are readable by authenticated (and mostly anon) but not by service_role. Any edge-function code that reaches for the service client — the normal way to bypass RLS — gets permission denied instead.
Reproduce
select c.relnamespace::regnamespace||'.'||c.relname as tbl
from pg_class c
where c.relkind='r'
and c.relnamespace::regnamespace::text in ('core','data','onet')
and has_table_privilege('authenticated', c.oid, 'SELECT')
and not has_table_privilege('service_role', c.oid, 'SELECT')
order by 1;core.archetypes
core.assessment_sessions
core.ipip_share_tokens
core.personality_assessments
core.portfolio_items
core.soft_skills
core.user_archetypes
core.user_assessment_xp
Or from a test:
await createAdminClient().schema("core").from("soft_skills").select("*").limit(1)
// { code: "42501", message: "permission denied for table soft_skills" }Why it matters
service_role is the bypass-everything role; a table it cannot read is almost always an oversight in the migration that created it, not a policy. core.soft_skills in particular is public reference data seeded by migration 001 — there is no reason to withhold it.
This is the same class as the grants gaps fixed by migrations 332 (api_keys) and 335 (scheduling).
Where it bit
Hit while fixing #464 (PR #479). GET /v1/profiles/:username resolves skill names from core.soft_skills; reading that catalog with the service client fails, so the route reads catalogs with the caller's client and only user-owned rows with the service client. That workaround is fine on its own merits, but it was forced rather than chosen — see the comment on resolveSkillNames in packages/supabase/functions/api/routes/profiles.ts.
Suggested fix
A grants migration following the shape of 332/335, granting service_role the privileges its siblings already have. Check INSERT/UPDATE/DELETE too — this query only tests SELECT.
Acceptance
- The query above returns zero rows.
createAdminClient().schema("core").from("soft_skills").select("*")succeeds.packages/supabase/functions/api/__tests__/routes/profiles.test.tsstill passes (it currently reads that catalog as anon specifically to dodge this).
Activity
feat(reviews): implement the ten endpoints the review wizard already …
test(api): fail when a route reads a table that does not exist
thinkclay commentedon Aug 27, 2026
Related instance found by a full sweep:
core.review_linksgrants only topostgres— noauthenticated, noservice_role— soGET /v1/reviews/linksandGET /v1/reviews/links/by-token/{token}both returnpermission denied, breaking review collection including the emailed reviewer link. Filed as #654 since it is a different table set from the eight here.The wider sweep (#660) found 45 references to tables that do not exist at all, which is the same failure mode one layer up: a table is created, or renamed, and the route that reads it is never checked. #651 adds a test that catches new instances of the missing-table half; the grants half is still only caught at runtime, so a companion check over
information_schema.role_table_grantswould close that gap too.test(api): fail when a route reads a table that does not exist (#651)
fix(api): review links were unreachable, and the org member list read…
fix(feedback): move user_feedback into core, so the router is reachab…
fix(feedback): move user_feedback into core, so the router is reachab…
fix(feedback): move user_feedback into core, so the router is reachab…
fix(feedback): move user_feedback into core, so the router is reachab…
feat(api)!: delete the employers route, and move user_feedback so /v1…
fix(db): drop four review-link policies 347 added that already existed (
fix(db): grant service_role the eight tables it could not read, and s…
thinkclay commentedon Sep 10, 2026
Fixed. The issue's own reproduction query now returns nothing:
All eight —
archetypes,assessment_sessions,ipip_share_tokens,personality_assessments,portfolio_items,soft_skills,user_archetypes,user_assessment_xp— now grant toservice_role.Closing on the local schema, which is the same migration set production runs. If someone confirms production separately and finds a gap, reopen.
fix(db): grant service_role the eight tables it could not read, and s…
fix(db): grant service_role on core.construction_projects (#732 follo…
fix(db): grant the roles six core policies already name (#755) (#758)