-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Summary
When adding a comment, if the user's profile picture URL has expired (R2 presigned URL), the avatar shows a broken image instead of the DiceBear initials fallback.
Root Cause
In src/routes/learn/$slug/-components/comment-list.tsx (lines 194-197):
src={
comment.profile.image ??
`https://api.dicebear.com/9.x/initials/svg?seed=...`
}The ?? operator only triggers fallback for null or undefined. An expired presigned URL is still a truthy string, so:
- Expired URL is used as img src
- Image fails to load (403)
- No
onErrorhandler exists to catch this and show fallback - Result: broken image
Steps to Reproduce
- Upload a profile picture
- Wait for R2 presigned URL to expire (~1 hour)
- Add a comment on any video segment
- Observe avatar shows broken image icon
Current Behavior
Broken image displayed when profile picture URL has expired.
Expected Behavior
DiceBear initials fallback should display when image fails to load.
Proposed Solution
Add onError handler to fall back gracefully:
<img
src={comment.profile.image ?? fallbackUrl}
onError={(e) => { e.currentTarget.src = fallbackUrl }}
alt="User avatar"
/>Or fix the root cause (issue #34) by not storing presigned URLs in the database.
Related Issues
- Fix profile picture disappearing after upload (possible R2 presigned URL expiration) #34 - Profile picture disappearing (presigned URL expiration)
Affected Areas
-
/src/routes/learn/$slug/-components/comment-list.tsx(lines 191-199, 355-363) -
/src/routes/learn/$slug/-components/comment-form.tsx(lines 125-132)
Acceptance Criteria
- Avatar shows DiceBear fallback when image URL fails to load
- No broken image icons visible in comments
coderabbitai
Metadata
Metadata
Assignees
Labels
No labels