Repository navigation
fix(api): the public profile's work-log strip called a route that did not exist (#447) - #616
Merged
Merged
Conversation
…d not exist (#447) WorkLogPortfolioWidget — the "Verified work history" section of every public profile — calls GET /v1/work-logs/public-feed. That route was never written, so the section was broken for every user since it shipped. Same for the show-on-profile toggle on WorkLogDetailScreen, which calls PATCH /v1/work-logs/{workLogId}/profile-visibility. Neither failed as a 404. GET /{workLogId} matched the path first and rejected "public-feed" as a malformed uuid: {"issues":[{"validation":"uuid","path":["workLogId"]}]} which reads like a client bug, and is why two dead endpoints sat unnoticed. public-feed returns the PublicWorkLog shape the widget actually consumes (camelCase, project and organization names joined, photos signed), not the WorkLogListItem the SDK's type claims — the widget carries an `as unknown as` cast today for exactly that mismatch. The publication rules are enforced server-side, since everything here is readable by anyone with a profile URL: status = verified WorkLogDetailScreen refuses the toggle without it; a client-side gate is not a rule show_on_profile the worker opted this log in photos.show_on_profile and opted each photo in separately `visibility` is deliberately not filtered on: it is org-scope sharing, and the profile toggle never writes it, so requiring both would leave the feed permanently empty regardless of what the worker turned on. show_date_range_on_profile is honoured by nulling logDate — the widget already renders "Date hidden by worker" for that. PATCH is owner-only (`.eq("user_id", user.id)`, 404 otherwise) rather than going through resolveAccessibleWorkLog: whether a log appears on a worker's public profile is the worker's call, not a collaborator's or an org admin's. Verified against a live stack: the feed returns the joined shape; toggling the date off nulls logDate; toggling show off empties the feed; a draft log opted in by direct SQL stays out; a photo with show_on_profile=false is excluded; PATCH on someone else's log 404s. Also adds a guard test for the ordering trap that caused this. A literal route declared after a sibling /{param} of the same method is unreachable, and the symptom names a parameter the caller never sent. The test parses the route files and fails with the line numbers and the fix, so the next one is a red test rather than a confusing 400. KNOWN_GAPS: 64 -> 62. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Sep 10, 2026
thinkclay
added a commit
that referenced
this pull request
Sep 11, 2026
…ave (#732) (#748) 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]>
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.
What was broken
WorkLogPortfolioWidget— the "Verified work history" section rendered on every public profile (app/(public)/users/[slug].tsx:237) — callsGET /v1/work-logs/public-feed. That route was never written. The section has been broken for every user since it shipped.Same for the show-on-profile toggle on
WorkLogDetailScreen: it callsPATCH /v1/work-logs/{workLogId}/profile-visibility, which also did not exist.Neither surfaced as a 404.
GET /{workLogId}matched the path first and rejected"public-feed"as a malformed uuid:{"issues":[{"validation":"uuid","code":"invalid_string","message":"Invalid uuid","path":["workLogId"]}]}That reads like a client bug, which is how two dead endpoints with live consumers went unnoticed.
The contract
public-feedreturns thePublicWorkLogshape the widget actually consumes — camelCase, project and organization names joined, photos signed — not theWorkLogListItemthe SDK's type claims. The widget carries anas unknown as PublicWorkLog[]cast today for exactly that mismatch.Publication rules, enforced server-side
Everything here is readable by anyone holding a profile URL, so the filters are the publication rule rather than a caller convenience:
status = verifiedWorkLogDetailScreenrefuses the toggle without it — a client-side gate is not a ruleshow_on_profilephotos.show_on_profilevisibilityis deliberately not filtered on. It is org-scope sharing, and the profile toggle never writes it (handleShowOnProfileTogglesendsshowOnProfilealone), so requiring both would leave the feed permanently empty no matter what the worker turned on.show_date_range_on_profileis honoured by nullinglogDate— the widget already renders "Date hidden by worker" for that case.PATCHis owner-only (.eq("user_id", user.id), 404 otherwise) rather than going throughresolveAccessibleWorkLog: whether a log appears on a worker's public profile is the worker's call, not a collaborator's or an org admin's.Verified against a live stack
PublicWorkLogshapelogDatenull,showDateOnProfilefalseshow_on_profile=falsePATCHon someone else's loglimit=999GET /work-logs/projectsandGET /{workLogId}API suite: 291 passed / 82 failed, identical failure set to
main(the pre-existing ES256 api-test breakage), with the 7 new tests passing on top.The ordering trap, now a test
A literal route declared after a sibling
/{param}of the same method is unreachable, and the symptom names a parameter the caller never sent — nothing about it says "your route is in the wrong place".literal-routes-precede-params.test.tsparses the route files and fails with the offending line numbers and the fix. It only flags same-method, same-segment-count collisions (soPATCH /{workLogId}does not falsely shadowGET /public-feed), and three self-tests assert the detector actually fires rather than passing vacuously.I had this wrong mid-investigation and said so publicly — I tested
/projectsagainstPATCH /{workLogId}at line 392 without checking the method, concluded order did not matter, and was about to rewrite the guidance. The real pair isGET /projects(506) declared beforeGET /{workLogId}(711). Movingpublic-feedabove the param route was the entire fix. The comments inreviews.tsandskill-analytics.tsare restored to the correct guidance, and this test exists so it is not a matter of remembering.KNOWN_GAPS: 64 → 62.🤖 Generated with Claude Code