Skip to content

fix(api): both /v1/profiles slug endpoints always 500 — org selects 5 nonexistent columns, core.employers does not exist #482

Closed

Description

@thinkclay

GET /v1/profiles/organizations/:slug and GET /v1/profiles/employers/:slug both return 500 for every request. These are the 10 failures #464 set aside as "missing from the local schema cache" — that diagnosis is wrong for the organizations half, and the employers half is worse than it sounds.

Actual causes

Organizations — 5 tests. core.organizations exists. The route selects columns it does not have:

column organizations.industry does not exist

packages/supabase/functions/api/routes/profiles.ts:913 selects industry, size, location, founded_year and filters .eq("is_public", true). The real table has:

id, owner_user_id, name, slug, industry_id, logo_url, website, description,
address, geo, visibility, search_tsv, created_at, updated_at, ...

So five referenced fields are absent: industry (there is an industry_id FK), size, location (there is address/geo), founded_year, and is_public (there is visibility). OrganizationProfileSchema promises all of them.

Employers — 5 tests. core.employers does not exist in any schema:

Could not find the table 'core.employers' in the schema cache

The route at profiles.ts:1030 queries it anyway, and the fixture inserts into it.

Reproduce

cd packages/supabase && deno test --allow-all --no-check \
  --config=functions/api/deno.json functions/api/__tests__/routes/profiles.test.ts

10 failures, all in the organizations and employers groups. (The other 17 pass as of #479.)

Why this needs a decision first

Not mechanical:

  • Organizations: does industry resolve through industry_id, and where do size and founded_year come from — new columns, or dropped from the response schema? Is location address, geo, or a formatted composite? is_public presumably becomes a visibility check, but the values matter.
  • Employers: is this a real concept that was never migrated, or dead code to delete along with its route, schema and tests? The legacy tRPC routers do not reference core.employers either.

Either answer is reasonable; picking one without product input risks freezing the wrong contract into a public endpoint.

Pointers

  • Route: packages/supabase/functions/api/routes/profiles.ts (org ~913, employer ~1030)
  • Response schemas: same file, ~485 and ~502
  • Tests + fixtures: packages/supabase/functions/api/__tests__/routes/profiles.test.ts

Acceptance

  • Both endpoints return 200 with populated fields, or the employers endpoint and its schema/tests are removed outright.
  • The full profiles suite passes (27/27, or 22/22 if employers is dropped).
  • Response schemas match columns that actually exist.

Activity

  1. added
    bug
    needs-design
    on Jul 30, 2026
  2. thinkclay commented on Aug 27, 2026

    @thinkclay
    ContributorAuthor

    The organizations half of this is fixed — #617 (merged). GET /v1/profiles/organizations/{slug} now selects the real columns, joins core.industries through industry_id, and filters on visibility; it returns 200 with a correct job_count (verified 4 against 4 open jobs). The two profiles.test.ts cases it was failing now pass.

    That PR also fixed a second bug hiding behind this one: both job counts filtered status = "published", which core.jobs' CHECK constraint does not permit (draft|open|paused|closed), so every employer showed 0 open jobs. It was invisible because the route 500'd before reaching the count.

    The employers half is #618 — it queries core.employers, a table in no schema, and has no UI consumer, so it needs a decision rather than a fix.

    Both are now rolled up under #660, and #651 adds a test that fails on any new reference to a nonexistent table.

  3. added 2 commits that reference this issue on Sep 11, 2026
    c60e257
    e76f414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-designpriority: hightype: backend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions