Skip to content

Fixed image upload crash and added URL paste support for profile images#229

Open
kushbosamiya wants to merge 2 commits intoshopstr-eng:mainfrom
kushbosamiya:fix/image-upload-validation-and-url-paste
Open

Fixed image upload crash and added URL paste support for profile images#229
kushbosamiya wants to merge 2 commits intoshopstr-eng:mainfrom
kushbosamiya:fix/image-upload-validation-and-url-paste

Conversation

@kushbosamiya
Copy link

@kushbosamiya kushbosamiya commented Feb 15, 2026

fixing #215

Uploading an image on the shop profile or user profile page crashes with
"Cannot read properties of undefined (reading toString)"

This happens because the blossom server response is used directly without
checking the HTTP status or validating that the expected fields exist.
If the server returns an error or an incomplete response, response.size.toString()
blows up.

Additionally, users who already have images hosted on blossom or any URL
are forced to re-upload them -- there is no way to just paste a URL.

Changes

Bug fix -- blossom upload crash (nostr-helper-functions.ts)

  • Check res.ok before parsing the JSON response
  • Throw a descriptive error if the server returns a non-200 status
  • Validate that response.url and response.sha256 exist before using them
  • Use String(response.size) with a null check instead of bare .toString()

Feature -- paste image URL (file-uploader.tsx)

  • Added an optional allowUrlInput prop to FileUploaderButton
  • When enabled, renders a text input where users can paste an image URL directly
  • Validates the URL before accepting it (must be http/https)
  • Backward compatible -- existing callers without the prop are unaffected

Wired up URL paste on profile and community forms

  • shop-profile-form.tsx (component)
  • user-profile-form.tsx (component)
  • pages/settings/shop-profile.tsx
  • pages/settings/user-profile.tsx
  • CreateCommunityForm.tsx

Testing

  • Log in with Amber or any signer
  • Go to shop profile settings, try uploading an image -- should no longer crash
  • Paste a blossom/image URL into the new input field and click Use URL -- image should appear
  • Same flow works on user profile and community creation forms

kushbosamiya added 2 commits February 15, 2026 19:03
…om server response before accessing properties, check HTTP status, added optional URL input for pasting hosted image URLs
- Restrict image URL input to HTTPS-only, aligning validation logic
  with the error message and enforcing secure URLs for profiles/communities.
- Include `size` in Blossom server response validation so incomplete
  responses are rejected instead of silently falling back to "0".
@vercel
Copy link

vercel bot commented Feb 15, 2026

Someone is attempting to deploy a commit to the shopstr-eng Team on Vercel.

A member of the Team first needs to authorize it.

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