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
onError handler 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
Affected Areas
Acceptance Criteria
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):The
??operator only triggers fallback fornullorundefined. An expired presigned URL is still a truthy string, so:onErrorhandler exists to catch this and show fallbackSteps to Reproduce
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
onErrorhandler to fall back gracefully:Or fix the root cause (issue #34) by not storing presigned URLs in the database.
Related Issues
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