OWASP / OWASP/Nest

# 🚫 Avoid Passing Empty String to `src` Prop in Next.js `<Image />` Component

Open Beginner friendly
#1,605 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
451
Forks
707
Avg merge
22h 59m
Merged PRs (30d)
91

Description

## Description

While reviewing the code in `RecentReleases.tsx`, I noticed the following pattern:

```tsx
src={item?.author?.avatarUrl || ''}
```

Passing an empty string (`''`) to the `src` prop of the Next.js `` component is not recommended. According to the [Next.js documentation](https://nextjs.org/docs/pages/api-reference/components/image#src), the `src` must be a valid, non-empty string. Using an empty string can lead to:

- Console warnings
- Failed network requests
- Broken image icons in the UI

---

## ✅ Recommended Fix

Instead of defaulting to an empty string, consider either:

**1. Passing `undefined`:**
```tsx
src={item?.author?.avatarUrl || undefined}
```

**2. Conditionally rendering the `` component:**
```tsx
{item?.author?.avatarUrl && (
{item?.author?.name
)}
```

---

## 📄 Reference

- [Next.js Image Component Documentation](https://nextjs.org/docs/pages/api-reference/components/image#src)

![Image](https://github.com/user-attachments/assets/787535e1-9bb6-48b7-9cb4-339001de05a9)

Contributor guide

Open the contributing guide

Research direction

Open RecentReleases.tsx and inspect the Image component's avatarUrl handling. Compare the available fallback approaches with the Next.js Image documentation, then verify that missing avatar URLs no longer produce an empty src and that the release list still renders correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, react, typescript
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.