fix(member-profile): restore photo upload and fix preview ReferenceError#4267
Draft
fix(member-profile): restore photo upload and fix preview ReferenceError#4267
Conversation
Two bugs caused profile photo uploads to silently revert to the default
avatar after saving:
1. `saveProfile()` never included `photo_url` in the submitted formData.
For individual profiles the photo maps to `resolved_brand.logo_url`;
the fix persists a changed URL value via a direct call to
`PUT /api/me/member-profile/brand-identity` after the main profile
save succeeds. Data URLs from the file-picker are rejected by the
server (https-only, 2000-char limit) — the fix surfaces a clear
message instead of a silent 400.
2. `const parsed` was declared inside a `try {}` block but referenced
outside it, causing `ReferenceError: parsed is not defined` whenever
the photo preview ran against a valid https URL (i.e. every profile
load with an existing photo). The fix restructures the guard to use
`img.src = photoUrl` directly and wraps the URL-validation block so
data-URL previews also render after a file selection.
https://claude.ai/code/session_01Eaet96RXhtpp46SciTWcdS
Generated by npm run build as part of pre-PR build gate for #4260. https://claude.ai/code/session_01Eaet96RXhtpp46SciTWcdS
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 #4260
Two bugs caused profile photo uploads on
/member-profileto silently revert to the default avatar after saving, with no error shown to the user.Bug 1 —
saveProfile()dropped the photo silently. TheformDataobject never includedphoto_url, so all photo changes were discarded at form submission. For individual profiles the photo field maps toresolved_brand.logo_url; the fix persists a changed URL value via a directPUT /api/me/member-profile/brand-identitycall after the main profile save succeeds. The direct fetch bypasses the_brandSavingguard used by the interactive brand section. Data URLs fromhandleLogoUpload()are explicitly guarded: the server rejects them (checkLogoUrlIsImagerequireshttps:, and base64 blobs exceed the 2000-char limit), so the fix surfaces a clear message — "please host your image and paste the URL" — instead of a silent 400.Bug 2 —
ReferenceError: parsed is not definedinupdatePhotoPreview().const parsedwas declared inside atry {}block but referenced outside it. This threw on every profile load that had an existing photo URL (the normal case), silently breaking the preview. The fix restructures the guard to useimg.src = photoUrldirectly and skips URL-format validation fordata:URIs so freshly-uploaded file previews also render.Non-breaking justification: changes are confined to
server/public/member-profile.html(client-side UI only). No schema, task definition, API surface, or protocol field is touched; existing consumers and callers are unaffected.Pre-PR review:
Nits (not fixed, tracked for follow-up):
photoUrl.startsWith('data:')to set expectations earliermessage; brand-identity route also returnserror— consistent with existing pattern at line 2838 but worth a follow-up sweepclearLogo→ empty field) does not persist the clear to the server; a follow-up should send{ logo_url: null }to brand-identity when the field was non-empty beforeSession: https://claude.ai/code/session_01Eaet96RXhtpp46SciTWcdS
Generated by Claude Code