Skip to content

feat(api)!: delete the employers route, and move user_feedback so /v1/feedback works - #708

Closed
thinkclay wants to merge 2 commits into
claude/660-schema-refsfrom
claude/618-665-dead-routes
Closed

thinkclay wants to merge 2 commits into
claude/660-schema-refsfrom
claude/618-665-dead-routes

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Stacked on #706 (which is stacked on #704). Review those first; this branch's own diff is its last two commits.

Both of these are routes that have never worked, for the same underlying reason as the rest of #660: the code addresses a schema that isn't there.


#618 — delete GET /v1/profiles/employers/{slug}

It queried core.employers:

select table_schema||'.'||table_name from information_schema.tables
where table_name ilike '%employer%';
-- (0 rows)

select count(*) from information_schema.columns
where table_schema='core' and column_name='employer_id';
-- 0

No employers table in any schema, no employer_id column anywhere in core. The handler also counted jobs by employer_id. There was nothing to repair toward — this was written against a schema that does not exist, not one that drifted.

employer in this product is an organization: core.organizations carries owner_user_id, core.jobs.organization_id is the real FK, and GET /v1/profiles/organizations/{slug} already does the job (repaired in #617).

Deleted: the route; the SDK's EmployerProfile, profiles.getEmployer and useEmployerProfile (Scaffald/sdk#21, merged, pointer bumped here); the scf-core wrapper hook and its re-export; and the five Deno tests plus the createTestEmployerProfile helper that inserted into core.employers.

Why nothing caught this. The SDK tests mocked /v1/profiles/employers/:slug in msw and asserted against the mock, so they were green for the entire life of an endpoint that 500s. A mock of an endpoint that cannot exist proves only that the client can parse an object someone made up.

core.employers is dropped from BASELINE_BROKEN — with the route gone the entry is stale, and the reference test fails on stale entries rather than letting them rot.

BREAKING CHANGE. The endpoint, profiles.getEmployer, useEmployerProfile and EmployerProfile are gone. Since it never returned a response, no working behaviour is removed.


#665 — move logs.user_feedback to core.user_feedback

Every feedback endpoint failed for any client, for two independent reasons:

  1. PostgREST does not serve the logs schema (config.toml exposes auth, public, core, storage, data, onet, engagement, community).
  2. The table granted only postgres — no service_role, no authenticated. Same class as fix(db): 8 core tables grant SELECT to authenticated but not service_role #481 and core.review_links grants only postgres — both review-link endpoints 500 #654.

Migration 350 takes the smaller of the two routes the issue offered: move the table rather than expose a ninth schema. That keeps the exposed-schema list stable across all three environments, and core is already the convention for user-scoped data. logs held nothing else.

The table is empty, so nothing migrates but the definition. SET SCHEMA carries indexes, constraints, the RLS setting and all three policies — which were already correct:

user_feedback_select_self          SELECT to authenticated  USING (user_id = auth.uid())
user_feedback_insert_self          INSERT to authenticated  WITH CHECK (user_id = auth.uid())
user_feedback_service_full_access  ALL    to service_role

What was missing was never the policies but the grants beneath them. A policy cannot widen access past an absent GRANT, which is why even service_role could not read it.

Verified against the running stack

before after
PostgREST, core.user_feedback "Could not find the table in the schema cache" resolves the table
as anon — 42501 permission denied — correct, feedback requires auth
as authenticated — query runs

CCPA

GET /v1/ccpa/data-summary counts platform feedback again. #663 deliberately left it out of the Communications category rather than report a silent zero in a statutory disclosure; with the table reachable, the category is now "Reviews, platform feedback" and its count includes both.

Closes #618
Closes #665

@thinkclay
thinkclay force-pushed the claude/660-schema-refs branch 2 times, most recently from 1e40910 to d5dab1b Compare September 2, 2026 06:17
…in no schema

`GET /v1/profiles/employers/{slug}` has never returned a response. It queried
`core.employers`, and information_schema has no `employers` table in any schema
and no `employer_id` column anywhere in `core` — the route was written against
a schema that does not exist, not one that drifted. The handler also counted
jobs by `employer_id`, so there was nothing to repair toward.

`employer` in this product is an organization: `core.organizations` carries
`owner_user_id`, and `core.jobs.organization_id` is the real FK.
`GET /v1/profiles/organizations/{slug}` already does what this route appears to
want, and works (#617).

Deleted: the route, the SDK's `EmployerProfile` / `profiles.getEmployer` /
`useEmployerProfile` (Scaffald/sdk#21, pointer bumped here), the scf-core
wrapper hook and its re-export, and the five Deno tests plus the
`createTestEmployerProfile` helper that inserted into `core.employers`.

`core.employers` is dropped from BASELINE_BROKEN — with the route gone the
entry is stale, and the reference test fails on a stale entry rather than
letting it rot.

BREAKING CHANGE: `GET /v1/profiles/employers/{slug}` is gone, along with
`profiles.getEmployer`, `useEmployerProfile` and `EmployerProfile`. It never
returned a response, so no working behaviour is removed. Use
`GET /v1/profiles/organizations/{slug}` and `useOrganizationProfile`.

Closes #618

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay force-pushed the claude/618-665-dead-routes branch from 92c2ea3 to 2722855 Compare September 2, 2026 06:18
…le at all

Every /v1/feedback endpoint failed for any client, for two independent reasons
(#665):

  1. PostgREST does not serve the `logs` schema. config.toml exposes auth,
     public, core, storage, data, onet, engagement and community.
  2. logs.user_feedback granted only `postgres` — no service_role, no
     authenticated. Same class as #481 and #654.

Migration 350 takes the smaller of the two routes offered in the issue: move
the table rather than expose a ninth schema. That keeps the exposed-schema list
stable across all three environments, and core is already the convention for
user-scoped data. `logs` held nothing else.

The table is empty, so nothing is migrated but the definition. SET SCHEMA
carries its indexes, constraints, RLS setting and all three policies, which
were already correct and role-scoped — select/insert to authenticated on
`user_id = auth.uid()`, ALL to service_role. What was missing was never the
policies but the grants beneath them: a policy cannot widen access past an
absent GRANT, which is why even service_role could not read it.

Verified against the running stack. Before, PostgREST answered "Could not find
the table in the schema cache". Now it resolves the table and answers 42501 for
`anon` — which is the correct outcome, since feedback requires auth and only
authenticated and service_role are granted. As `authenticated`, the count runs.

The CCPA data summary counts platform feedback again. #663 left it out of the
Communications category rather than reporting a silent zero in a statutory
disclosure; with the table reachable, the category is "Reviews, platform
feedback" and its count includes both.

Closes #665

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant