Repository navigation
Conversation
Completes the vanity-URL surface: the SDK's `getProfileBySlug` was the last of the four slug methods still hitting a route that did not exist. Public by design (no requireAuth, matching the legacy tRPC publicProcedure) and registered after the static /slug/check and /slug/history routes, which would otherwise be swallowed as slugs — "check" and "history" both satisfy the slug pattern. Response is unenveloped to match SDK ProfileBySlug. Reads profile_visibility with the service client rather than the request-scoped one. core.preferences is owner-only under RLS (preferences_own_all), so the RLS client returns nothing for every visitor except the owner — which would hand each visitor the permissive defaults and render sections the owner had hidden. This is a deliberate departure from the tRPC original, which had that bug. Defaults still apply when no row exists, with contact_info false so the one PII-bearing flag fails closed. Co-Authored-By: Claude Opus 5 <[email protected]>
Contributor
Author
|
Closing as a duplicate of #439, which does the same thing better. I built this without realising #439 was already open and adding the same endpoint. #439 is the more complete implementation:
It also already reads Verified that #439 still merges cleanly onto |
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.
Follow-up to #441, which added
GET /v1/profiles/slug/checkandPATCH /v1/profiles/slug. This adds the last of the four SDK vanity-URL methods still hitting a route that did not exist:getProfileBySlug.What this adds
GET /v1/profiles/slug/{slug}→ProfileBySlug, unenveloped (the SDK's http client returns the body verbatim, so a{ data }wrapper would deserialize into the wrong shape without failing loudly).Public by design — no
requireAuth— matching the legacy tRPCpublicProcedurethis is ported from.Registration order is load-bearing and covered by a test. The route is registered after the static
/slug/checkand/slug/historyroutes from #441. Bothcheckandhistorysatisfy the 3–50 char^[a-z0-9-]+$slug rule, so a param route registered first would swallow them.One deliberate departure from the tRPC original
profile_visibilityis read with the service client, not the request-scoped one.core.preferencesis owner-only under RLS (preferences_own_all), so the RLS client returns no row for any visitor except the owner, and the tRPC version then fell through to its permissive defaults. A profile owner who hid their work history had it advertised as visible to every anonymous visitor. The data behind those sections is separately RLS-gated, so this was not a data leak — but the vanity page would render sections the owner had switched off.The service-role read is scoped to one column for the one profile being rendered. Defaults still apply when no row exists, with
contact_info: falseso the only PII-bearing flag fails closed.Covered by
honours the owner's visibility settings, which sets flags as the owner and asserts an anonymous visitor sees them.Tests
6 new cases in
profiles.test.ts, taking the slug suite from 11 to 17: profile resolution, visibility honouring, thecontact_infodefault, the static-route shadowing guard, 404, and 400. They useassertStatusrather thanassertSuccessResponse, which requires adatakey.The resolution test asserts response shape rather than seeded values, because
createTestUserProfile'score.usersinsert is a silent no-op — a trigger already creates the row on auth signup, so the insert fails on the pkey and the fixture never checks the error. That same fixture bug is why three/{username}tests fail onmain; fixing it is out of scope here.17/17 green locally against this branch's base, stable across runs.
pnpm prepushpasses (build + test + Deno load probe).CI
Checks on this PR are uninformative: every job fails in 3–5s with "The job was not started because recent account payments have failed or your spending limit needs to be increased." No job starts, and
main's own runs fail identically.🤖 Generated with Claude Code