Repository navigation
fix(api): repair profiles fixture and the public-profile reads it masked - #479
Merged
Merged
Conversation
…ked (#464) createTestUserProfile inserted core.users and core.profile rows that the core.handle_new_user trigger had already created. Both inserts failed with duplicate-key errors that were never checked, so every seeded value was silently discarded and the trigger's defaults were asserted against instead. Both writes are now error-checked upserts. The helper also drops a leftover fixed-email auth user and retries once: [email protected] survives any run that dies before cleanupCurrentTestData, and then breaks every later run. Fixing the fixture exposed three real defects in GET /v1/profiles/:username, which had been returning empty skills, empty certifications and a null location to every anonymous caller: - The skills embed selected skill:skills(name), but no user_skills -> skills FK exists and core.skills has no non-test references. core.user_skills is a taxonomy table, so names are now resolved against data.masterformat, onet.occupation_data or core.soft_skills per row. - The certifications embed targeted core.certifications while certification_id references data.certifications, which carries no issuer column. name/issuer now come from the freeform columns, falling back to the catalog title. - location, user_skills and user_certifications were read with the caller's client, but anon holds no grant on any of them. They are now read with the service client, projecting only the fields ProfileSchema declares public. The catalogs stay on the caller's client: they already grant SELECT to anon, and core.soft_skills grants nothing to service_role. The skills and certifications fixtures no longer write catalog rows, so consecutive runs no longer poison each other. Fixes #464 Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Jul 30, 2026
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.
Fixes #464.
The reported bug
Confirmed before changing anything —
createTestUserProfileinserts acore.usersrow thecore.handle_new_usertrigger has already created:Unchecked, so every seeded value was discarded and the tests asserted against the trigger's defaults.
The issue undercounts it by one: the
core.profileinsert fails identically (profile_pkey), solocationwas never seeded either. Both writes are now error-checked upserts.The helper also drops a leftover fixed-email auth user and retries once.
[email protected]survives any run that dies beforecleanupCurrentTestData, and then breaks every later run at user creation — this happened twice during verification, once from a concurrent run in another worktree.The reported fix was not sufficient
Repairing the fixture moved test 1's failure from
display_nametolocationand left tests 2 and 3 failing. Three further defects, all in the route rather than the fixture:select("skill:skills(name)")— nouser_skills → skillsFK exists (PGRST200), andcore.skillshas no non-test references anywhere in the reposkills: []core.certifications, butcertification_idreferencesdata.certifications— which carries no issuer column at allcertifications: []core.profile,core.user_skillsandcore.user_certificationswere read with the caller's client;anonholds no grant on any of themlocation: nullSo
GET /v1/profiles/:usernamewas returning empty skills, empty certifications and a null location to every anonymous viewer. Verified on a local database — prod grants are worth confirming separately, I did not check them.Changes
ProfileSchemaalready declares public. Catalogs stay on the caller's client: they already grant SELECT toanon, andcore.soft_skillsgrants nothing toservice_role.data.masterformat/onet.occupation_data/core.soft_skills), batched one query per catalog.certification_id.Verification
The 10 are the
core.organizations/core.employersschema-cache failures the issue scopes out. All 11 slug tests, which share the helper, still pass.deno fmtanddeno lintclean.pnpm prepushdid not run: this worktree has nonode_modules, sonx affected -t build/testcould not execute. The change is Deno-only edge-function code that nx does not build; the suite load-probe, lint, fmt and the full touched suite all pass. Flagging it rather than papering over it.🤖 Generated with Claude Code