vercel/next.js · error · ImageError
"url" parameter is valid but upstream response is invalid
Error message
"url" parameter is valid but upstream response is invalid
What it means
Redirect-loop guard in fetchExternalImage: the upstream response was a redirect whose Location could still be parsed, but the redirect budget (count) was exhausted — too many redirects. Continuing would loop forever, so the optimizer gives up and throws ImageError 508 declaring the upstream response invalid.
Solutions
- Verify the upstream URL returns a valid image response (correct status and content-type).
Defensive patterns
Strategy: fallback
When it happens
Trigger: The upstream image response is not valid.
Common situations: The remote server returns a non-200 status or bad content for an optimized image.
AI-assisted analysis of vercel/next.js@996f957c06 (2026-08-19).
Data as JSON: /api/errors/414b32026165ec7a.
Report an issue: GitHub.
Appendix: source
Thrown at packages/next/src/server/image-optimizer.ts:575
if (err.name === 'TimeoutError') {
Log.error('upstream image response timed out for', href)
throw new ImageError(
504,
'"url" parameter is valid but upstream response timed out'
)
}
throw err
}
const locationHeader = res.headers.get('Location')
if (
isRedirect(res.status) &&
locationHeader &&
URL.canParse(locationHeader, href)
) {
if (count === 0) {
Log.error('upstream image response had too many redirects', href)
throw new ImageError(
508,
'"url" parameter is valid but upstream response is invalid'
)
}
const redirect = new URL(locationHeader, href).href
return fetchExternalImage(
redirect,
dangerouslyAllowLocalIP,
maximumResponseBody,
count - 1
)
}
if (!res.ok) {
Log.error('upstream image response failed for', href, res.status)
throw new ImageError(
res.status,
'"url" parameter is valid but upstream response is invalid'View on GitHub (pinned to 996f957c06)