Skip to content

fix(api): the public profile's work-log strip called a route that did not exist (#447) - #616

Merged
thinkclay merged 1 commit into
mainfrom
claude/feat-worklog-public-feed
Aug 12, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/feat-worklog-public-feed

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

What was broken

WorkLogPortfolioWidget — the "Verified work history" section rendered on every public profile (app/(public)/users/[slug].tsx:237) — calls GET /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 calls PATCH /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-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 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:

filter why
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 (handleShowOnProfileToggle sends showOnProfile alone), so requiring both would leave the feed permanently empty no matter 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 case.

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

check result
feed returns the joined PublicWorkLog shape ✅ project + org names resolved
toggle date off → logDate null, showDateOnProfile false ✅
toggle show off → feed empties ✅
draft log opted in by direct SQL (bypassing the client gate) ✅ stays out
photo with show_on_profile=false ✅ excluded; opted-in one returned signed
PATCH on someone else's log ✅ 404
unauthenticated / bad uuid / limit=999 ✅ 401 / 400 / 400
GET /work-logs/projects and GET /{workLogId} ✅ no regression

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.ts parses the route files and fails with the offending line numbers and the fix. It only flags same-method, same-segment-count collisions (so PATCH /{workLogId} does not falsely shadow GET /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 /projects against PATCH /{workLogId} at line 392 without checking the method, concluded order did not matter, and was about to rewrite the guidance. The real pair is GET /projects (506) declared before GET /{workLogId} (711). Moving public-feed above the param route was the entire fix. The comments in reviews.ts and skill-analytics.ts are 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

…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]>
@thinkclay
thinkclay merged commit f1e1a27 into main Aug 12, 2026
5 of 10 checks passed
@thinkclay
thinkclay deleted the claude/feat-worklog-public-feed branch August 12, 2026 12:41
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant