Skip to content

fix(profile): the skills widget on another user's profile was broken three ways (#603) - #610

Merged
thinkclay merged 1 commit into
mainfrom
claude/fix-603-skills-widget
Aug 12, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/fix-603-skills-widget

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #603. Part of #594.

SkillsWidget is rendered on every other-user profile via user-profile-right. It called useSkillsLegacy(), and three separate things were wrong with that.

1. The endpoint does not exist. GET /v1/profiles/skills/legacy returns 404 — never registered on the api function — so the widget could only ever render "Failed to load skills".

2. It fetched the wrong person. useSkillsLegacy() takes no userId, so it reads the authenticated user's skills. The widget is passed userId and rendered on other people's profiles. Fixing (1) alone would have shipped a worse bug than it fixed: your own skills displayed as theirs.

3. The shape was a fiction. The response was cast as unknown as EnrichedUserSkill[] — a shape GetSkillsLegacyResponse has never had. LegacySkill is {skill_id, skill_name, proficiency, …}; the widget renders {id, taxonomy, name, label, displayCode, …}.

The fix

Migrated to useSkillsWidget({ userId }) → GET /v1/profiles/widgets/skills, which exists, is userId-aware, and whose SDK type SkillWidgetEntry is exactly the shape the widget renders — so the cast goes too.

Except that endpoint didn't return that shape either. It did select("*") on core.user_skills and returned raw rows, which carry only a taxonomy discriminator and a foreign key — no name, no display code — while its own OpenAPI response schema declared name/label/displayCode. Anything rendering label got an empty string. It now resolves them.

The resolution is extracted to lib/skill-lookups.ts rather than written a second time: /v1/profiles/skills/multi-taxonomy already resolves the same two foreign keys inline. The two endpoints shape their responses differently on purpose, so this shares the lookup, not the response — which is what stops them drifting on the part that matters, which table a taxonomy resolves against. #585 was two copies of one rule disagreeing; worth not repeating.

useSkillsLegacy / useUpdateSkillsLegacyMutation are removed — SkillsWidget was their only consumer. The matching SDK methods live in the @scaffald/sdk submodule and are now unreferenced; removing them needs its own PR there.

Correcting the other half of #603

I reported GET /v1/profiles/skills/user as 404 with live consumers in the work-log picker. That was wrong. client.skills.getUserSkills() requests /v1/profiles/skills, which exists and returns data — I had inferred the path from the hook's query key (['scaffald','skills','user']) and probed a URL nothing calls. The work-log skill picker was never broken. Only the legacy pair was real.

Verification

  • 43 new Deno assertions in __tests__/lib (11 for the lookup helper), 0 failures — including the trimmed-O*NET-code case, dedup, the no-ids short circuit, and unresolved skills still rendering a label rather than an empty row.
  • 338 scf-core profile assertions across 43 files, 0 failures, no file-level collection failures.
  • deno check on the changed route: 56 errors, identical to the HEAD baseline (all the pre-existing untyped-context issue, fix(api): authMiddleware context is untyped, so c.get() is never and test:deno:types cannot pass #477).
  • scf-core typechecks at 0 errors; pnpm prepush green.

Not verified against a live database. Another session cycled the local Supabase stack and restored a pre-seed backup partway through this work (data.masterformat went 8,953 → 0), so I did not re-probe the endpoint rather than reset a database someone else is using.

CI checks will show red without running — Actions billing block, #375.

🤖 Generated with Claude Code

…three ways (#603)

SkillsWidget is rendered on every other-user profile via user-profile-right. It
called useSkillsLegacy(), and three separate things were wrong with that.

1. The endpoint does not exist. GET /v1/profiles/skills/legacy returns 404 —
   the route has never been registered on the api function, so the widget could
   only ever render its "Failed to load skills" state.

2. It fetched the wrong person. useSkillsLegacy() takes no userId, so it reads
   the *authenticated* user's skills. The widget is passed userId and rendered
   on other people's profiles, so fixing (1) alone would have shipped a worse
   bug than the one it fixed: your own skills displayed as theirs.

3. The shape was a fiction. The response was cast
   `as unknown as EnrichedUserSkill[]`, a shape GetSkillsLegacyResponse has
   never had — LegacySkill is {skill_id, skill_name, proficiency, ...}, the
   widget renders {id, taxonomy, name, label, displayCode, ...}.

Migrated to useSkillsWidget({ userId }) -> GET /v1/profiles/widgets/skills,
which exists, is userId-aware, and whose SDK type (SkillWidgetEntry) is exactly
the shape the widget renders — so the cast is gone too.

That endpoint did not actually return that shape. It did `select("*")` on
core.user_skills and returned the raw rows, which carry only a taxonomy
discriminator and a foreign key: no name, no display code. Its own OpenAPI
response schema declared name/label/displayCode. Anything rendering `label` got
an empty string. It now resolves them.

The resolution logic is extracted to lib/skill-lookups.ts rather than written a
second time — /v1/profiles/skills/multi-taxonomy already resolves the same two
foreign keys inline. The two endpoints shape their responses differently on
purpose, so this shares the lookup, not the response; sharing the lookup is what
stops them drifting on the part that matters, which table a taxonomy resolves
against. #585 was two copies of one rule disagreeing, and that is worth not
repeating.

useSkillsLegacy and useUpdateSkillsLegacyMutation are removed — SkillsWidget was
their only consumer. The matching SDK methods live in the @scaffald/sdk
submodule and are now unreferenced; removing them needs its own PR there.

Also corrects the other half of #603: I reported GET /v1/profiles/skills/user as
404 with live consumers. That path is not what the client calls —
client.skills.getUserSkills() requests /v1/profiles/skills, which exists and
returns data. I had inferred the path from the hook's query key
(['scaffald','skills','user']) and probed a URL nothing uses. The work-log skill
picker was never broken.

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay merged commit 5e97fe3 into main Aug 12, 2026
5 of 11 checks passed
@thinkclay
thinkclay deleted the claude/fix-603-skills-widget branch August 12, 2026 09:06
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.

fix(api): two skills endpoints 404 with live consumers — work-log picker and other-user profiles

1 participant