Repository navigation
fix(api): serve public profile sections to the audience those pages have (#732) - #748
Merged
Merged
Conversation
…ave (#732) Found smoke-testing production as an anonymous visitor — the audience a public profile exists for. Every section endpoint the page calls answered 401: /v1/profiles/widgets/general-info 401 /v1/profiles/widgets/experience 401 /v1/profiles/widgets/education 401 /v1/profiles/widgets/skills 401 /v1/profiles/widgets/certifications 401 /v1/work-logs/public-feed 401 /reviews/by-subject 401 So scaffald.com/users/clay rendered "No profile data available", "No work experience added yet" and "No verified work logs are currently visible on this profile" for a profile that has all three. A visitor cannot tell an empty profile from a gated one, and neither can a crawler — these pages are in sitemap-users.xml. ## The product decision was already made I filed this asking which sections are public. They are already decided, in code: GET /v1/profiles/slug/{slug} serves anonymously and returns a `visibility` object from core.preferences.profile_visibility — work experience, education, skills, certifications and reviews public by default, contact info not, each overridable by the owner. The page reads that object to decide what to render, then asked for the data and was refused. The endpoints simply never honoured the rule the page was already being told. lib/profile-visibility.ts is that rule in one place rather than copied into six handlers, with a test asserting its defaults match the ones in profiles.ts — if those drift, the page renders a section the data endpoint then refuses. ## Why the auth check was there at all Each handler did `if (!user) return 401` and then `userId || user.id`. The check existed to make that fallback possible: without a caller there is no "me". An explicit userId needs no fallback, which is what makes an anonymous read of a named public profile possible at all. No userId still requires auth. ## Authorization versus mechanism core.user_experience, user_education and user_certifications carry owner-only SELECT policies, so a viewer's own client reads nothing of someone else's profile however the owner published it. The visibility check is the authorization; the service client is only how it is carried out — the same split profiles.ts already documents for /slug/{slug}. Reading your own profile stays on your own client, so RLS still applies there. A hidden section answers 404, not 403: 403 would confirm the section exists and was hidden, which is the one thing the owner asked not to reveal. ## work-logs/public-feed was my own mistake I built it in #616 for WorkLogPortfolioWidget, which renders only on app/(public)/users/[slug].tsx, gated it on `if (!user)`, and verified it with an authenticated caller. It was reachable in exactly the case it was not built for. Its filters — verified status, the worker's show_on_profile opt-in, a per-photo opt-in — are the publication rule, and none of them depend on who is asking. reviews/by-subject contradicted its own table: core.reviews carries reviews_read as SELECT to {anon, authenticated} USING (true). The 401 was the only thing stopping the page showing them; the owner's `reviews` flag still hides them. Verified against a live stack, anonymously and signed in: anonymous, visible section 200 anonymous, owner hid it 404 a different signed-in user, hidden 404 owner, implicit "me" 200 owner, explicit own id 200 no userId, anonymous 401 /widgets/preferences, anonymous 401 Co-Authored-By: Claude Opus 5 <[email protected]>
4 tasks
Contributor
📊 Performance Benchmark Results |
thinkclay
added a commit
that referenced
this pull request
Sep 11, 2026
…g them Clears BASELINE_MISMATCHES to empty. Nine were real and are fixed in Scaffald/sdk#30; two were this test's own false positives. **Seven declared the payload against a route that wraps** — apiKeys.update, apiKeys.getUsage, connections.accept, connections.send, engagement.track, follows.followJob, follows.followUser. They now unwrap, as 39 other methods in the SDK already do, rather than widening the signature. That is the fix that makes callers work rather than merely type-check: useUpdateApiKeyMutation already declares `UseMutationOptions<ApiKey, …>`, so the hook, the screens and the type were all right and only the runtime value was wrong. **Two declared an envelope their route does not send,** and this one was live. personalityAssessments.getStatus and getIPIPStatus declared `{ data: … }`; probed against the running api, both routes answer bare. So every consumer reading `status?.data` was reading undefined: PersonalityAssessmentWidget.tsx const assessment = assessmentData?.data usePersonalityAssessment.ts const assessment = assessmentData?.data useAssessmentStatus.ts cast through `{ data?: … }` to compile All three corrected here. A fourth, LuscherTestWizard.tsx, already carried the workaround *and the diagnosis* — "SDK type declares { data: AssessmentStatus } but API returns AssessmentStatus directly", with a `??` fallback that made that one screen work while the other three silently did not. Now that the type is right, the fallback goes too. Typecheck found that fourth site on its own once the declaration stopped lying, which is the argument for fixing the type rather than the call sites. **Two were the guard's false positives.** auth.getUserRoles and jobs.officeDuplicateJob do unwrap, through spellings the detector did not recognise: return { roles: response.data.roles } // reshapes while unwrapping .then((res) => res.data) const response = (await this.get<…>(p)) as {…} // parenthesised cast Detection is now precise about the thing that matters: find the name the response is bound to, then ask whether the body reads `.data` off it. Widening it that way first hid four real unwraps in background-checks and feedback, because the binding regex did not allow the parenthesised form — caught by the baseline's own stale check, which is what that half of the guard is for. Re-attacked after the change, since a too-permissive detector would mask the class it exists to catch: reverting engagement.track to its pre-fix form is still reported as "sdk says bare, route says wrapped", and legitimate unwrapping is still not flagged. Also runs deno fmt over three files this branch does not otherwise touch — __tests__/lib/profile-visibility.test.ts, __tests__/routes/public-profile-sections.test.ts and routes/profile-widgets.ts, all from #748. They fail `Lint REST API Code` on main, and formatting them makes that check pass rather than fail less. scf-core typecheck and its 1151 tests pass; deno fmt and lint clean; the contract directory is 9/9. Closes #744 Co-Authored-By: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 11, 2026
…g them (#750) Clears BASELINE_MISMATCHES to empty. Nine were real and are fixed in Scaffald/sdk#30; two were this test's own false positives. **Seven declared the payload against a route that wraps** — apiKeys.update, apiKeys.getUsage, connections.accept, connections.send, engagement.track, follows.followJob, follows.followUser. They now unwrap, as 39 other methods in the SDK already do, rather than widening the signature. That is the fix that makes callers work rather than merely type-check: useUpdateApiKeyMutation already declares `UseMutationOptions<ApiKey, …>`, so the hook, the screens and the type were all right and only the runtime value was wrong. **Two declared an envelope their route does not send,** and this one was live. personalityAssessments.getStatus and getIPIPStatus declared `{ data: … }`; probed against the running api, both routes answer bare. So every consumer reading `status?.data` was reading undefined: PersonalityAssessmentWidget.tsx const assessment = assessmentData?.data usePersonalityAssessment.ts const assessment = assessmentData?.data useAssessmentStatus.ts cast through `{ data?: … }` to compile All three corrected here. A fourth, LuscherTestWizard.tsx, already carried the workaround *and the diagnosis* — "SDK type declares { data: AssessmentStatus } but API returns AssessmentStatus directly", with a `??` fallback that made that one screen work while the other three silently did not. Now that the type is right, the fallback goes too. Typecheck found that fourth site on its own once the declaration stopped lying, which is the argument for fixing the type rather than the call sites. **Two were the guard's false positives.** auth.getUserRoles and jobs.officeDuplicateJob do unwrap, through spellings the detector did not recognise: return { roles: response.data.roles } // reshapes while unwrapping .then((res) => res.data) const response = (await this.get<…>(p)) as {…} // parenthesised cast Detection is now precise about the thing that matters: find the name the response is bound to, then ask whether the body reads `.data` off it. Widening it that way first hid four real unwraps in background-checks and feedback, because the binding regex did not allow the parenthesised form — caught by the baseline's own stale check, which is what that half of the guard is for. Re-attacked after the change, since a too-permissive detector would mask the class it exists to catch: reverting engagement.track to its pre-fix form is still reported as "sdk says bare, route says wrapped", and legitimate unwrapping is still not flagged. Also runs deno fmt over three files this branch does not otherwise touch — __tests__/lib/profile-visibility.test.ts, __tests__/routes/public-profile-sections.test.ts and routes/profile-widgets.ts, all from #748. They fail `Lint REST API Code` on main, and formatting them makes that check pass rather than fail less. scf-core typecheck and its 1151 tests pass; deno fmt and lint clean; the contract directory is 9/9. Closes #744 Co-authored-by: Claude Opus 5 <[email protected]>
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.
Closes #732.
Found smoke-testing production as an anonymous visitor — the audience a public profile exists for. Every section endpoint the page calls answered 401, so
scaffald.com/users/clayrendered "No profile data available", "No work experience added yet" and "No verified work logs are currently visible on this profile" for a profile that has all three.A visitor cannot tell an empty profile from a gated one, and neither can a crawler — these pages are in
sitemap-users.xml.The product decision was already made
I filed this asking which sections should be public. They are already decided, in code.
GET /v1/profiles/slug/{slug}serves anonymously and returns avisibilityobject fromcore.preferences.profile_visibility— work experience, education, skills, certifications and reviews public by default, contact info not, each overridable by the owner.The page reads that object to decide what to render, then asks for the data and is refused. The endpoints never honoured the rule the page was already being handed.
lib/profile-visibility.tsis that rule in one place rather than copied into six handlers, with a test asserting its defaults match the ones inprofiles.ts— if those drift, the page renders a section the data endpoint then refuses, or hides one it would have served.Why the auth check was there at all
Each handler did
if (!user) return 401thenuserId || user.id. The check existed to make that fallback possible — without a caller there is no "me". An explicituserIdneeds no fallback, which is what makes an anonymous read of a named public profile possible. NouserIdstill requires auth.Authorization vs mechanism
core.user_experience,user_educationanduser_certificationscarry owner-only SELECT policies, so a viewer's own client reads nothing of someone else's profile however the owner published it. The visibility check is the authorization; the service client is only how it's carried out — the same splitprofiles.tsalready documents. Reading your own profile stays on your own client, so RLS still applies there.A hidden section answers 404, not 403 — 403 would confirm the section exists and was hidden, which is the one thing the owner asked not to reveal.
work-logs/public-feedwas my own mistakeI built it in #616 for
WorkLogPortfolioWidget, which renders only onapp/(public)/users/[slug].tsx— then gated it onif (!user)and verified it with an authenticated caller. It was reachable in exactly the case it wasn't built for. Its filters (verified status,show_on_profile, per-photo opt-in) are the publication rule, and none depend on who is asking.reviews/by-subjectcontradicted its own table:core.reviewscarriesreviews_readas SELECT to{anon, authenticated} USING (true). The 401 was the only thing stopping the page showing them. The owner'sreviewsflag still hides them.Verified against a live stack
userId, anonymous/widgets/preferences, anonymous18 new tests. The route guards assert the rules rather than the wiring, because the wiring is easy to reintroduce — an
if (!user) return 401added to a section handler looks locally sensible and silently empties every public profile again.One pre-existing failure in
sdk-envelopes.test.ts(GET /v1/profiles/:p,/v1/profiles/organizations/:p) is unrelated — confirmed identical with my changes stashed.🤖 Generated with Claude Code