Repository navigation
fix(api): two org endpoints with live screens, and a job count that could only ever be 0 (#447) - #617
Merged
Merged
Conversation
…ould only ever be 0 (#447) Two more routes with UI already calling them: GET /v1/organizations/{id}/open-jobs-count the "N open jobs" figure on OrganizationPreviewModal, ProfileHoverCard and the employer detail pane — all three reachable from /workers/map and /employers/{id}. Every one fell back to its `return 0` branch. GET /v1/organizations/{id}/background-checks OrganizationBackgroundChecksPage, mounted at /office/ats/checks. That page has never loaded data. Found while implementing the first one: core.jobs.status is CHECK (draft|open|paused|closed), and both job counts in profiles.ts filtered on status = "published" — a value the column cannot hold. They returned 0 for every employer. Counting the wrong status is indistinguishable from an employer having no jobs, which is why it sat there. That fix was unverifiable at first, because GET /v1/profiles/organizations/{slug} answered 500 before ever reaching the count: {"error":"Internal Server Error","message":"column organizations.industry does not exist"} The select asked for industry, size, location and founded_year and filtered on is_public. None of the five exist. The route had never returned a profile. It now selects the real columns, joins core.industries through industry_id, and filters on visibility — and the job count reads 4 against 4 open jobs in the database. Authorization for the background-check list is the sensitive part: those rows carry consent timestamps, adverse-action dates and findings about named people. The predicate was already written inline three times in organizations.ts, so it is extracted to lib/org-access.ts with tests rather than copied a fourth time. Owner, org-scoped role, or platform admin/super_admin. A non-member gets 404 and not 403, so the endpoint does not confirm which org ids exist. Being the *subject* of a check grants nothing here — a worker reads their own through GET /v1/background-checks. Verified against a live stack: count matches the database exactly; the check list returns newest-first and honours ?status= and ?limit=; a platform super_admin reads it; the subject of both checks, who is not an org member, gets 404; so does an org id that does not exist; limit=999 is rejected. API suite: 305 passed / 80 failed, against 284 / 82 on main. Zero newly failing; the two newly passing are the org-profile tests this repairs. KNOWN_GAPS: 62 -> 60. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Aug 12, 2026
This was referenced Aug 27, 2026
Closed
Merged
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…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
added a commit
that referenced
this pull request
Sep 2, 2026
…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
added a commit
that referenced
this pull request
Sep 2, 2026
…/feedback works (#712) * feat(profiles)!: delete the employers route, which addressed a table 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]> * fix(feedback): move user_feedback into core, so the router is reachable 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]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
thinkclay
added a commit
to Scaffald/sdk
that referenced
this pull request
Sep 10, 2026
…ever sent (#26) `GET /v1/profiles/organizations/{slug}` was repaired in Scaffald/SaaS#617 — the select used to ask for columns core.organizations does not have — but the type above it was left alone. Checked against a live response rather than reasoned about: field declared actually returned description string object (rich-text document) industry string object { id, name, slug } size string ABSENT location string ABSENT founded_year number ABSENT address - returned, undeclared And one more at the top level: the route wraps its payload in `{ data }`, and the http client returns the body verbatim, so `getOrganization` resolves to `{ data: OrganizationProfile }` while declaring the profile bare. size, location and founded_year are dropped rather than added. They exist in no table in any schema, so keeping them would mean inventing product surface to satisfy a type that was only ever aspirational. **Why the suite never noticed.** The msw handler hand-wrote the declared shape — `industry: 'Technology'`, `size: '1000-5000'`, `location: 'San Francisco, CA'` — and returned it bare. Every assertion was `toHaveProperty`, which passes against any shape at all. So the tests agreed with the type, the type disagreed with the API, and nothing connected the two. Same failure as the employers mock in #21: mocking an endpoint into the shape you wish it had proves only that the client can parse an object you wrote yourself. The handler now mirrors a real response, and four assertions check the things that were wrong — description is a document, industry is the embedded row, address is structured, and size/location/founded_year are absent. Verified they bite: reverting `industry` to a string in the mock turns one red. `useOrganizationProfile`'s generic follows the envelope, which is what caught the top-level mismatch — tsc rejected the old `UseQueryOptions<OrganizationProfile>` as soon as the method stopped lying. `getUser` has the same envelope defect and `getProfileBySlug` does not wrap at all; that inconsistency spans the public profiles surface and is filed separately rather than half-fixed here. tsc clean; 776 tests across 36 files pass. Refs Scaffald/SaaS#482 Co-authored-by: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 11, 2026
…as never sent (#743) #617 repaired the select behind GET /v1/profiles/organizations/{slug} — it used to ask for industry, size, location and founded_year and filter on is_public, none of which exist on core.organizations — but the response schema above it was left as written. So the endpoint has been returning 200 while its published OpenAPI contract, and the SDK type generated from it, were wrong in six ways. Checked against a live response rather than reasoned about: field declared actually returned description string object (rich-text document) industry string object { id, name, slug } size string ABSENT location string ABSENT founded_year number ABSENT address - returned, undeclared Nothing broke visibly: @hono/zod-openapi documents responses rather than validating them, and no screen imports useOrganizationProfile. The SDK tests passed throughout because their msw handler hand-wrote the declared shape, so they asserted against a response the API cannot produce (fixed in Scaffald/sdk#26, pointer bumped here). size, location and founded_year are dropped rather than added. No table in any schema has those columns — a search of information_schema.columns matches nothing outside pg_catalog and storage — so keeping them would mean inventing product surface to satisfy a schema that was only ever aspirational. `address` is the real column behind what it called `location`. Verified after the change: every declared field matches the live response by type, and no undeclared field is returned. deno check on profiles.ts is unchanged at 3 errors — all pre-existing members of the TS2345 handler-response family measured in #704, two of them on routes this does not touch. One trap is recorded in the code rather than left for the next reader: supabase-js types the embedded to-one relation as an array because it cannot infer cardinality from the select string, so the static type says `industry: {...}[]` while the wire format is an object. The schema follows the wire format. Closes #482 Co-authored-by: Claude Opus 5 <[email protected]>
This was referenced Sep 11, 2026
thinkclay
added a commit
that referenced
this pull request
Sep 11, 2026
… hid an anonymous-viewer bug (#745) Closes #482. The organizations route was fixed in #617 and its schema in #743, but profiles.test.ts still asserted the phantom contract — industry as a string, size, location, founded_year, an is_public fixture flag — so the suite stayed red at 24/27 after the code was right. The three tests now assert what the table has: industry joined through industry_id to a real core.industries row, address as the jsonb object it was stored as, and an explicit check that none of the four phantom columns come back. The fixture seeds visibility, industry_id and address, and throws on insert errors instead of returning whatever the swallowed failure left behind. Two things the old tests could never have caught surfaced on the way: The job-count test inserted jobs with status "published", which core.jobs' CHECK (draft|open|paused|closed) rejects; the insert error was unawaited, so the count it expected (2) was unreachable. Now "open", and the error throws. The 27th test — a vanity slug resolving to a profile with a location — was red for a reason outside #482 and inside #732: GET /v1/profiles/slug/{slug} read core.profile with the request client, and every SELECT policy on that table is granted to `authenticated` (profile_public_read is `true`, so every signed-in viewer sees it). Anonymous viewers, the audience the public page exists for, got location: null. The read now goes through the service-role client alongside the preferences read that already did, after the user row is resolved, so nothing about who can find a profile changes. Verified against the running API: 27/27, with the edge runtime confirmed to be serving this worktree (it had been serving another one — the memory-noted gotcha — for the earlier runs). Fixed-name fixtures poisoned reruns: a run that died before cleanup left acme-corp / private-org behind and every later run hit organizations_slug_key. Slugs are now unique per run. tests/infrastructure/vitest/mocks/beyond-ui.tsx: Tabs was a bare div, so any screen using Tabs.Item / Tabs.Trigger / Tabs.Content threw "Element type is invalid". That is what kept two IPIPResultsPage tests skipped since #566 and what stopped the XP-award test from ever rendering the page it asserted on. Tabs is now a compound; both skips are lifted, and a regression test for #740 renders the page three times plus a tab switch and asserts the award fires once — with the hook mock returning a fresh object per call, as useMutation does, because a shared object cannot reproduce the loop. SDK pointer: 759b7ec -> sdk main (Scaffald/sdk#26 + #28). #743 recorded the bump to #26 in its description but main still pointed at sdk#25 — and #26 itself was red at 7: it moved the type, method and tests to the { data } envelope but not the msw handler. sdk#28 fixes the handler; 776/776. This is what `pnpm prepush` refused to stamp until it was fixed, which is the gate doing its job. profiles 27/27 · scf-core IPIPResultsPage 7/7 (was 4 + 2 skipped) and the three other Tabs-consuming suites 32/32 · scf-core:typecheck · sdk 776/776 · deno check profiles.ts unchanged at the 5 pre-existing errors · prepush stamped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two more gaps with UI already calling them
GET /v1/organizations/{id}/open-jobs-countOrganizationPreviewModal,ProfileHoverCard, employer detail pane — reachable from/workers/mapand/employers/{id}return 0GET /v1/organizations/{id}/background-checksOrganizationBackgroundChecksPage, mounted at/office/ats/checksA job count that could only ever be 0
Found while implementing the first one.
core.jobs.statusisCHECK (draft|open|paused|closed), and both job counts inprofiles.tsfiltered onstatus = "published"— a value the column cannot hold.Every employer showed 0 open jobs. Counting the wrong status is indistinguishable from an employer genuinely having none, which is why it went unnoticed.
…inside a route that 500'd before reaching it
The fix was unverifiable at first, because
GET /v1/profiles/organizations/{slug}never got that far:{"error":"Internal Server Error","message":"column organizations.industry does not exist"}The select asked for
industry,size,location,founded_yearand filtered onis_public. None of the five exist oncore.organizations. The route had never returned a profile in its life.It now selects the real columns, joins
core.industriesthroughindustry_id, and filters onvisibility— and the job count reads 4 against 4 open jobs in the database.Authorization
The background-check rows carry consent timestamps, adverse-action dates and findings about named individuals, so the gate is the part worth reviewing.
The predicate was already written inline three times in
organizations.ts(/{id}/location-visibility,/{id}/projects-with-overrides, and now this). It is extracted tolib/org-access.tswith 12 tests rather than copied a fourth time — a copied authorization check is one that can drift.admin/super_adminGET /v1/background-checksworker,office) does not pass — scope alone is not enough, and there is a test for thatVerified against a live stack
open-jobs-countvs the database?status=+?limit=?limit=999GET /v1/organizations/{id}API suite: 305 passed / 80 failed, against 284 / 82 on
main. Failure sets diffed by name: zero newly failing; the two newly passing areGET /v1/profiles/organizations/:slug - returns 0 job count if no jobsand- returns 404 if not found, which this repairs.Not in scope
GET /v1/profiles/employers/{slug}queriescore.employers, which does not exist in any schema, and there is noemployer_idcolumn anywhere incore. It also has no UI consumer. Filed separately rather than guessed at here — it needs a decision about whether the route should exist at all.KNOWN_GAPS: 62 → 60.🤖 Generated with Claude Code