Skip to content

Hand Astro only remote artwork it can load - #129

Merged
RobbieTheWagner merged 2 commits into
mainfrom
fix/unreachable-artwork
Dec 5, 2026
Merged

RobbieTheWagner merged 2 commits into
mainfrom
fix/unreachable-artwork

Conversation

@RobbieTheWagner

Copy link
Copy Markdown
Member

Why

Starpod should build a site from whatever a podcast host's feed serves. We're running the e2e suite against a small fixture feed that covers the odd things real feeds do. Building that fixture turned up this bug. When an episode's <itunes:image> URL answers 404, the whole build fails under an adapter that resizes images at build time. That means Astro's own sharp service, as with @astrojs/node, which #126 makes Starpod's default. One dead artwork link in a real feed takes the whole site down.

Error generating image for http://127.0.0.1:4599/missing.jpg: Error: Failed to load remote image http://127.0.0.1:4599/missing.jpg. The request did not return a 200 OK response. (received 404))

whiskey.fm never saw this. The Vercel image service fetches nothing at build time.

Root cause

optimizeImage, the explorer's cardArt and faceOf call getImage inside try/catch and expect to fall back when it fails. In a build, getImage only plans a remote image's transform and never fetches it, so it never throws. Astro fetches the image later, in its image generation pass (assets/build/generate.js, then loadRemoteImage). It collects that failure and exits 1. The same happens for a URL that answers 200 with something that isn't an image (NoImageMetadata).

Fix

lib/remote-image.ts adds getLoadableImage, a getImage that first reads each remote image once per URL. The read uses Astro's own inferRemoteSize from astro:assets. It follows redirects the way the build does and checks them against the integration's remotePatterns (flightcast 307s to signed S3 URLs). It also confirms the body is an image, and it stops reading once it knows the dimensions. A 10s deadline keeps a stalled art host from hanging the build. An image Astro cannot load is refused like any other getImage error, so each caller's existing fallback applies. That is the raw URL in optimizeImage, the thumbnail or show art in cardArt, and the avatar in faceOf. The three call sites switch to it.

In astro dev nothing crashed before or after. Before, the page pointed at an /_image URL that answered 500. Now it points at the raw URL.

Cost

The check runs on every adapter, Vercel included. Against whiskey.fm's feed, 265 distinct <itunes:image> URLs checked concurrently took 1.4 to 2.1s of wall time over 9 runs. In 1 of those 9 runs one URL failed transiently. That episode would fall back to its raw, unoptimized URL for that build, which still loads in a browser.

Verification

  • A minimal consumer site (@astrojs/node, local feed with one episode whose art 404s), not committed. astro build exits 1 before and 0 after, and the episode's stage <img> falls back to the raw URL. The same consumer also exits 0 with art that answers 200 HTML, and with an art host that never answers (the build took about 10s longer, and nothing hung).
  • tests/unit/remote-image.test.ts runs Astro's real probe against a stubbed fetch. It covers a loadable image, a 307 redirect to another host, a 404, an HTML page, a stalled host, and one fetch per URL. It lands one commit ahead of the fix: 4 of 5 fail without it. tests/unit/stubs/astro-assets.ts lets Vitest resolve astro:assets.
  • pnpm test:unit run (309 passed), pnpm lint, pnpm astro check (0 errors).

🤖 Generated with Claude Code

RobbieTheWagner and others added 2 commits December 4, 2026 09:01
A build fails when an episode's artwork URL is dead: getImage only plans
the transform, and Astro's later image pass fetches the URL and fails the
whole build on a 404 or a page that is not an image. These tests show
optimizeImage handing such URLs to Astro instead of falling back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getImage in a build only plans a remote image's transform; Astro fetches
it later and fails the build on one it cannot load. So one dead
<itunes:image> link failed the whole site under an adapter that resizes at
build, such as @astrojs/node.

getLoadableImage reads each remote image once per URL with Astro's own
inferRemoteSize (same redirect handling, and it confirms an image) under
a 10s deadline, and refuses one Astro cannot load, so the existing
fallbacks in optimizeImage, cardArt and faceOf apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RobbieTheWagner RobbieTheWagner added the bug Something isn't working label Dec 4, 2026
@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
starpod Ready Ready Preview Dec 4, 2026 2:03pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 93c13df and 32c07b4.

Files selected for processing: 7

  • packages/starpod/src/components/explorer/archive.ts
  • packages/starpod/src/lib/optimize-episode-image.ts
  • packages/starpod/src/lib/people.ts
  • packages/starpod/src/lib/remote-image.ts
  • tests/unit/remote-image.test.ts
  • tests/unit/stubs/astro-assets.ts
  • vitest.config.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@RobbieTheWagner
RobbieTheWagner merged commit fdb8531 into main Dec 5, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request Dec 5, 2026
RobbieTheWagner added a commit that referenced this pull request Dec 5, 2026
The back catalogue gains artwork that is gone (404) or a web page,
durations as HH:MM:SS and MM:SS, a guid with no attributes and none at
all, no itunes:episodeType, an itunes:summary alone, and a title in
numeric character references. feed-quirks.spec.ts checks what a listener
sees of each: dead artwork stays at its feed address, each duration reads
as its length, the plain-guid episode keeps its video, the summary is the
description, and the rest are numbered episodes with their own pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RobbieTheWagner added a commit that referenced this pull request Dec 5, 2026
The back catalogue gains artwork that is gone (404) or a web page,
durations as HH:MM:SS and MM:SS, a guid with no attributes and none at
all, no itunes:episodeType, an itunes:summary alone, and a title in
numeric character references. feed-quirks.spec.ts checks what a listener
sees of each: dead artwork stays at its feed address, each duration reads
as its length, the plain-guid episode keeps its video, the summary is the
description, and the rest are numbered episodes with their own pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RobbieTheWagner added a commit that referenced this pull request Dec 6, 2026
…base (#130)

* Build a fixture site for a made-up show, its URLs answered by MSW

tests/fixture-site is a Starpod site for a made-up show, built the way a
user's would be. One module (feed/episodes.ts) defines its episodes, people
and transcripts, and writes its feed. feed/routes.mjs answers every
fixture URL (*.fixture.example), and feed/msw.mjs preloads it into the
build, the dev server and the seed, failing them on any other request. The
media is generated colour bars and silence; the database is a local SQLite
file seeded from db/data.

Besides the episodes the suite opens, the back catalogue carries what real
feeds send: artwork redirected across hosts, named by a query, as PNG or
WebP, unlabeled, very large or over http; an enclosure behind a tracker's
redirects; escaped descriptions, markup and emoji in titles; and feed
transcripts with no type, the wrong Content-Type, missing, malformed or
empty. A unit test reads the feed through the site's own parser with the
same routes, and fails while the feed on disk and episodes.ts disagree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Run the e2e suite on the fixture site

Playwright builds the fixture site and serves it with the Node adapter
(E2E_DEV=1 serves it with the dev server), on port 4400 by default so it
never meets the whiskey.fm dev server. Every spec imports test from
tests/e2e/fixture.ts, which answers the fixture's media and artwork from
the build's own routes and fails a test whose page reaches anywhere else.

Slugs, titles, numbers and names come from feed/episodes.ts. Tests that
leaned on dev-only image URLs now check the image the page names is
resized; the MP3 stand-in route is gone, as the fixture's audio is short.
feed-quirks.spec.ts checks what a listener sees of the feed's quirks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Build the fixture site once in CI, for every browser, with no secrets

A fixture-site job builds it and uploads dist/, failing if the build holds
a database URL or a JWT; the three browser jobs serve it. No job gets the
database secrets. whiskey.fm gets a build check of its own from its live
feed, with a local database seeded from db/data. The scaffold job builds
against the fixture feed, answered by MSW, instead of flightcast.com.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Give the sections episode a real host's captions: short, unvoiced and many

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Skip the dock's audio test in CI's Firefox, which has no audio output

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Let Astro 7 read the fixture's fonts list and artwork through MSW

Astro 7's font resolver lists Google's fonts at fonts.google.com, so that
host passes through like the font files. Astro 7's image probe cancels a
response once it has the image's size, and MSW never settles cancel() on a
body it streams itself: every artwork timed out unread and the build kept
the feed's URLs. The fixture's answers are now streams that have already
ended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Add the feed quirks #127 and #129 let a build survive

The back catalogue gains artwork that is gone (404) or a web page,
durations as HH:MM:SS and MM:SS, a guid with no attributes and none at
all, no itunes:episodeType, an itunes:summary alone, and a title in
numeric character references. feed-quirks.spec.ts checks what a listener
sees of each: dead artwork stays at its feed address, each duration reads
as its length, the plain-guid episode keeps its video, the summary is the
description, and the rest are numbered episodes with their own pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Answer fixture byte ranges as a real host would, and serve artwork by plain id only

An oversized suffix range now returns the whole file, a range past the end
gets 416, and the image route refuses an id that could leave feed/files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Pass respond's range in the artwork test, as its type asks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep fixture file reads inside feed/files, and write cue times to the millisecond

A double-encoded dot segment passed the decoded-path check and resolved
outside feed/files; file() now checks where the URL resolved. Caption cues
at half seconds were written as whole seconds. CLAUDE.md now says the feed
writer also writes the markdown transcripts, and that the build lets Google
Fonts through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Say the fixture's episodes keep feed order, and find the oldest year by date

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 32c07b4f Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant