Skip to content

fix: tolerate Twitter CDN failures in web testimonials build#5995

Open
prql-bot wants to merge 1 commit into
mainfrom
fix/ci-27255107833
Open

fix: tolerate Twitter CDN failures in web testimonials build#5995
prql-bot wants to merge 1 commit into
mainfrom
fix/ci-27255107833

Conversation

@prql-bot

Copy link
Copy Markdown
Collaborator

Problem

build-web failed on main (run 27255107833) with a Hugo render error:

error calling GetRemote: Get "https://pbs.twimg.com/profile_images/1433982028/profile_normal.png": net/http: request canceled (Client.Timeout exceeded while awaiting headers)

section-testimonials.html downloads each testimonial's Twitter avatar at build time via resources.GetRemote. Per the Hugo docs, "if you do not handle the error yourself, Hugo will fail the build" — and only a 404 returns nil (the case the existing {{ with }}/{{ else }} handled). Any other HTTP request error, including a timeout, hard-fails the whole build. So a single slow or unreachable Twitter CDN fetch aborts build-web. The default image fetch on the line above had no error handling at all.

Solution

Wrap both remote fetches (the shared default image and each per-author avatar) in Hugo's try statement and inspect .Err. A failed fetch now logs a warnf and falls back instead of failing the build. A transparent 1×1 data-URI is the ultimate fallback, so the build no longer hard-depends on Twitter's CDN being reachable.

When the network is healthy the behavior is unchanged — real avatars are still downloaded and cached locally (which is why they're downloaded in the first place: Firefox tracking protection blocks pbs.twimg.com images for end users).

try is available since Hugo v0.141.0; the build-web job installs latest, so it's supported.

Testing

Reproduced and verified locally with Hugo v0.157.0 extended on a copy of web/website, pointing one testimonial at an unreachable host to force an HTTP request error:

  • Before: build fails with the exact CI error shape — section-testimonials.html:61:37 ... error calling GetRemote: ... connect: connection refused.
  • After: build succeeds (exit 0). The unreachable avatar emits WARN [section-testimonials.html] couldn't fetch remote image ... and renders /default.png; the other testimonials still fetch and cache their real pbs.twimg.com avatars normally.

Automated fix for failed run

resources.GetRemote fails the Hugo build on any HTTP request error
(e.g. a timeout), so a single slow or unreachable Twitter avatar fetch
aborted the entire build-web job. The previous `with`/`else` only
caught a 404 (which returns nil), not request errors.

Wrap both the default-image and per-author avatar fetches in `try` so a
failed fetch degrades to a fallback image with a warning instead of
failing the build. A transparent 1x1 data-URI is the ultimate fallback,
so the build no longer hard-depends on Twitter's CDN being reachable.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant