Repository navigation
fix(profile): stop General Information saving blanks over real data (#580, #587, #588) - #597
Merged
Merged
Conversation
…580, #587, #588) Three layers had to fail for a blank-overwrite to be possible, and all three were failing. Fixed together because fixing any one alone leaves the hole open. #580 — the form submitted its entire value object. When the GET failed, every field sat at generalProfileDefaults (empty strings throughout) and Save was gated on isDirty alone, so editing one field PATCHed first_name:"", last_name:"", phone:"" and a blank address over the user's real record. The form now refuses to render as an editable empty shell on a failed load (error state with Retry instead), and submits only dirty fields. The gate makes the wipe unreachable; the minimal patch means a future regression cannot make it reachable again. The dirty-field logic is extracted to buildGeneralInfoPatch so it is directly testable rather than buried in a 465-line component. #587 — PATCH /v1/profiles/general parsed the body as Record<string, unknown> and wrote whatever keys it found. No length caps, no type checks, no shape check on address, and `about` accepted arbitrary JSON. The client-side zod schema was the only enforcement anywhere, so any non-browser caller bypassed validation entirely. Now validated by a zod schema mirroring the client's limits, returning 400 with field-level detail. `.strict()` is deliberate: an unexpected `role` or `id` key should be a 400, not a silent no-op. #588 — both queries in GET /v1/profiles/general dropped their error. A grant gap or an RLS denial returned 200 with every field blank, which the client rendered as an editable empty form — the input to #580. Errors now 5xx, and `.single()` becomes `.maybeSingle()` so "no row yet" stays a legitimate empty result rather than an error. Also fixes two #591 defects in the same file, since they touch the same lines: the avatar could not be cleared (setValue without shouldDirty left Save disabled, and there is no other clear path), and nine console.log calls dumped the user's name, phone and home address to the console on every keystroke. A rejected submit now toasts instead of only console.logging, which previously made the Save button look like it had done nothing. Tests: 30 assertions on buildGeneralInfoPatch (scf-core) and 14 on the request schema (Deno), including the exact regression — a form left empty by a failed load, one field edited, patch contains only that field. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Aug 12, 2026
thinkclay
added a commit
that referenced
this pull request
Aug 12, 2026
* test: repoint the profile e2e specs at routes that exist, and run the Deno lib tests (#592) Twelve specs under tests/e2e/profile/ visited a URL space the app no longer serves. Seven targeted /profile/general, /profile/employment, /profile/education and /profile/certifications — all redirect stubs since the nine-screens-to-four consolidation — and asserted expect(page.url()).toContain(<old path>), which the redirect makes false. They now visit the live routes, and their titles name the section they actually exercise ("/profile/resume (General Information)") rather than a screen that was deleted. PROFILE_AUDIT_PLAN.md listed /dashboard/profile/*, a prefix the app has never served, and half its entries were screens that no longer exist. Replaced with the live route list plus an explicit stub-to-destination table. Separately: functions/api/__tests__/lib/*.test.ts was in no runner glob. test:api:rest:suite and the CI workflow both listed only routes/ and integration/, so profile-completion-calc.test.ts had never run, and neither had the schema tests added in #597 or the parity tests added in #601. Added to both, plus a standalone test:api:lib. That is 34 assertions moving from "written" to "executed". The profile specs are corrected but deliberately NOT added to testMatch yet. Turning them on needs one verified green run — Supabase up, api function served, dev server warm, seeded workers present — and this environment has no Docker, so they have been fixed but not executed. Adding them unrun would ship exactly the "known-red selection" playwright.config.ts already warns about. The config now carries the precise command to finish the job. Co-Authored-By: Claude Opus 5 <[email protected]> * test: run scf-core in the default suite (#593) scf-core holds every line of profile UI logic and was explicitly excluded from test:unit, so `pnpm test` and CI never ran any of it. 146 test files, ~1,000 assertions, none of them executing on the command the repo treats as "the tests". Running the suite directly: 955 passed, 61 skipped, 2 failed. It also completes — it does not OOM, contrary to the premise of #504. The `pool: 'forks'` workaround already in packages/scf-core/vitest.config.ts is doing its job; what remained was simply the exclude flag. The two failures were the same wrong assertion in two assessment widgets: expect(container.firstChild).toBeNull() renderWithProviders wraps in BeyondUIThemeWrapper, which renders a real element, so container.firstChild is that wrapper and can never be null. The assertion failed whether or not the widget rendered — it was testing the harness, not the component. Both now assert the widget's own testid is absent, which is what "should not render widget when assessment is completed" actually means. With those fixed the suite is green, so the exclude comes off. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
This was referenced Aug 12, 2026
Closed
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 #580, #587, #588. Also fixes two of the three defects in #591 (the two that live in this file). Part of #594.
The epic sequences these three as one PR because they are three layers of the same hole — client sends blanks, server hides the failure that caused them, server accepts anything. Fixing one alone leaves the path open.
#580 — the form submitted its entire value object
When the GET failed, every field sat at
generalProfileDefaults(empty strings throughout) and Save was gated onisDirtyalone. Editing one field PATCHedfirst_name:"",last_name:"",phone:""and a blank address over the user's real record.Two changes, deliberately belt-and-braces:
The dirty-field logic is extracted to
buildGeneralInfoPatchso it is directly testable instead of buried in a 465-line component that has never had a test.#587 —
PATCH /v1/profiles/generalhad no request validationIt parsed the body as
Record<string, unknown>and wrote whatever keys it found. No length caps, no type checks, no shape check onaddress, andaboutaccepted arbitrary JSON. The client-side zod schema was the only enforcement anywhere, so any non-browser caller bypassed it entirely.Now validated against a schema mirroring the client's limits, returning 400 with field-level detail. Extracted to
functions/api/lib/general-info-schema.tsso it can be unit-tested without the edge runtime..strict()is deliberate — an unexpectedroleoridkey should be a 400, not a silent no-op that lulls the caller into thinking it worked.#588 —
GET /v1/profiles/generalswallowed its errorsNeither query destructured
error. A grant gap (the class of bug in #481) or an RLS denial returned200with every field blank — which is precisely the input that made #580 destructive. Errors now return 5xx, and.single()becomes.maybeSingle()so "no row yet" stays a legitimate empty result rather than an error.#591 (partial)
Same file, same lines, so folded in rather than conflicting later:
setValue('avatar_path', '')withoutshouldDirtyleft Save disabled, and there is no other clear path — a user who uploaded an avatar could never remove it.console.logcalls dumped the user's name, phone and home address to the console on every keystroke. Removed. The two remainingconsole.errorcalls are genuine error logging and stay.console.log-only, so the Save button looked like it had simply done nothing.The third #591 item (the read-only email input being focusable/typable on web) is in this file too and is fixed here as well —
readOnly+aria-readonly+ removed from the tab order.Tests
general-info-patch.test.ts— 10 assertions, including the exact regression: a form left empty by a failed load, one field edited, patch contains only that field and none offirst_name/last_name/phone/address. Also covers the address-as-one-JSONB-column case, deliberately-cleared fields (falsy but dirty), and never sendingemail.general-info-schema.test.ts— 14 Deno assertions on the request contract: over-long names, non-string types, malformed address, out-of-range latitude, unknown keys, plus the shapes that must keep working (TipTap JSONContent, null about/address, cleared avatar).scf-coretypechecks at 0 errors;pnpm prepushgreen.CI
Checks on this PR will show red. They did not run — the Actions billing block (#375) has recurred and every gate job dies in 2–3s with "The job was not started because recent account payments have failed". See my comment on #375. Verification here is local: prepush runs build + tests.
🤖 Generated with Claude Code