Repository navigation
fix(api): add GET /v1/profiles/slug/{slug} so public profiles resolve - #439
Conversation
The SDK's getProfileBySlug has always called /v1/profiles/slug/{slug}, but
the api router only ever defined /{username}. Every public profile page
404'd and rendered "Profile Not Found".
Adding the endpoint rather than repointing the SDK at /{username}:
core.users.slug is an independent column, seeded from the username at
signup but user-changeable via the vanity-URL panel (30-day cooldown,
audited in core.slug_change_history). Slugs are meant to diverge, so a
slug lookup can't be folded into the username route. This also keeps the
fix out of the SDK submodule.
The response is unenveloped, unlike /{username} and the organization and
employer routes. The SDK hands callers the response body verbatim, so a
{data} wrapper would have produced a 200 with every field undefined
instead of an error. /general and /slug/history are already bare for the
same reason.
Section visibility is read with the service-role client: core.preferences
is RLS-scoped to its owner, so a public viewer's client reads nothing and
every hidden section would fall back to the permissive default and leak.
Also on the same page:
- Point the SSR loader at the new endpoint so the server render and the
client query agree once a slug diverges. Its own comment documented
this gap.
- Stop keying the not-found branch on `error`, which threw away good
loader data whenever the client query failed and turned a transient
fetch error into a 404.
- Pass loader visibility through, so hidden sections stay out of the
server-rendered HTML that crawlers see.
Verified against the local stack: diverged slug resolves by slug, legacy
rows fall back to username, unknown slugs 404, /slug/history is not
shadowed by the new param route, and preferences-driven visibility is
reflected in the response.
Co-Authored-By: Claude Opus 5 <[email protected]>
The getProfileBySlug 404 fixed in the previous commit existed because the
SDK and the Hono router drifted with nothing checking they agree. That
failure mode is silent and expensive: the request 404s and the UI renders
an empty or "not found" state with no error near the cause.
This parses both sides statically — 449 registered routes across 75
mounted sub-routers, 498 SDK call sites — and asserts every SDK path has
a matching route. Static rather than runtime because the api function
only imports inside the Supabase edge runtime; bare `hono` is not
resolvable under plain Deno.
The SDK turns out to be well ahead of the api, so KNOWN_GAPS records the
85 endpoints the SDK calls that nothing implements. The point is to stop
that list growing, not to pretend it is empty. Notable clusters:
- jobs defines no POST/PATCH/DELETE at all, so createJob, updateJob and
deleteJob cannot work
- profiles is missing /slug/check and PATCH /slug, so the vanity-URL
panel can read slug history but cannot change a slug
- the SDK asks for /v1/communities/posts/portfolio/{userId} where the
route is mounted at /user/{userId} — a wrong path segment
The baseline is enforced in both directions: a new gap fails, and so does
a stale entry, so implementing an endpoint forces its line to be removed
rather than letting the baseline quietly rot.
Verified by breaking things on purpose. Renaming the /slug/{slug} route
path reproduces the original bug and the test names exactly
`GET /v1/profiles/slug/:p`; adding an already-implemented endpoint to
KNOWN_GAPS trips the stale check. Guard assertions fail the run if either
parser stops recognising a registration style, so a parser regression
cannot turn this green by accident.
Co-Authored-By: Claude Opus 5 <[email protected]>
Tasks filed in local dev do not survive `supa db reset`. The first copy of these four was destroyed by exactly that: the stack was reset mid-session, the seeded `dogfooding-md` tasks came back because they live here, and everything else was gone. Filing a finding in the product is not durable on its own. Adds the four findings from the PR #439 session — the two remaining slug write endpoints, the silent response-envelope inconsistency, the contradictory dogfood-log status output, and the contract test itself (done) — with the same fixed-UUID ON CONFLICT DO NOTHING shape as the migrated entries, so they reconcile with the rows already in local databases instead of duplicating them. Verified by deleting all four and re-running the seed: all four come back with the right punchlist, status and priority, and a second run is a no-op. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Heads-up from an adjacent session: #441 landed on I checked how it interacts with this branch, so you don't have to:
Worth re-running the contract test after you rebase — three of the 85 baseline entries from #447 are now implemented ( I had duplicated the |
|
Triaged. Not redundant with #441 — but I am leaving this open rather than merging, because I could not verify it at runtime in this environment. Details below. It is still needed#441 ("implement the two missing vanity-URL slug endpoints") merged the two authenticated vanity endpoints. There is still no What I did verify
What blocks final verificationThe 4 new That checkout has no The tests assert I did not restart the edge runtime against this worktree, because another session is actively using the one currently mounted. To finish this offServe the api from this branch's checkout and re-run: pnpm supa functions serve apithen Given CI is still billing-blocked (#375), I did not want to merge an unverified runtime path on static review alone — that is the failure mode that has bitten this repo before. |
main is currently red on the contract test. #439 landed the test with an 85-entry baseline captured before #441 merged; #441 implemented two of those entries, so the stale-entry assertion now fires on every run: GET /v1/profiles/slug/check PATCH /v1/profiles/slug That is the assertion doing its job — it exists so a baseline cannot quietly drift out of date — but it needs the two lines removed. Baseline drops 85 -> 83. Verified red before and green after: checked out origin/main in a scratch worktree and reproduced the failure naming both entries, then confirmed 3/3 pass with this change. Co-authored-by: Claude Opus 5 <[email protected]>
Problem
The SDK's
getProfileBySlughas always called/v1/profiles/slug/{slug}, but the api router only ever definedGET /{username}. Every public profile page (/users/[slug]) 404'd and rendered Profile Not Found.Why add the endpoint instead of repointing the SDK
core.users.slugis an independent column — unique-indexed, seeded from the username at signup (004_functions.sql), then user-changeable via the vanity-URL panel with a 30-day cooldown and acore.slug_change_historyaudit trail (018_vanity_url_support.sql). Slugs are designed to diverge from usernames, so a slug lookup can't be folded into the username route. This also keeps the fix out of the SDK submodule (no PR + dist rebuild + pointer bump).The envelope
The new route is unenveloped, unlike
/{username},/organizations/{slug}and/employers/{slug}.packages/sdk/src/http/client.tsreturnsawait response.json()verbatim andProfileBySlugexpects fields at the top level — a{data}wrapper would have produced a 200 with every fieldundefinedrather than an error./generaland/slug/historyin the same router are already bare for this reason.Privacy note
Section visibility is read with the service-role client.
core.preferencesis RLS-scoped to its owner (preferences_own_all), so a public viewer's anon client reads nothing and every hidden section would silently fall back to the permissive default.Also fixed on the same page
error ||, so a transient client-query failure discarded good SSR data and rendered a 404. Now keyed on absent data.Verification
Exercised the router in-process against the local stack (the edge container mounts the main checkout, not the worktree, so this could not go through Kong):
/slug/historyis not shadowed by the new param route (401, not 404)education/reviewsfalse in preferences, the response reports them false — confirming the service-role readdeno lintclean,tsc --noEmitclean,pnpm prepushgreen (build + test).Not browser-verified end-to-end — that needs the api served from this worktree.
5 regression tests added in
profiles.test.ts. NoteassertSuccessResponserequires adatakey, so the unenveloped tests useassertStatus.Follow-up (not in this PR)
checkSlugAvailability(GET /slug/check) andupdateSlug(PATCH /slug) are still missing from the api, so the vanity-URL panel cannot actually change a slug. Any new static/slug/*route must be registered before/slug/{slug}or it will be shadowed.🤖 Generated with Claude Code