fix: tolerate Twitter CDN failures in web testimonials build#5995
Open
prql-bot wants to merge 1 commit into
Open
fix: tolerate Twitter CDN failures in web testimonials build#5995prql-bot wants to merge 1 commit into
prql-bot wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
build-webfailed onmain(run 27255107833) with a Hugo render error:section-testimonials.htmldownloads each testimonial's Twitter avatar at build time viaresources.GetRemote. Per the Hugo docs, "if you do not handle the error yourself, Hugo will fail the build" — and only a404returnsnil(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 abortsbuild-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
trystatement and inspect.Err. A failed fetch now logs awarnfand 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.comimages for end users).tryis available since Hugo v0.141.0; thebuild-webjob installslatest, 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:section-testimonials.html:61:37 ... error calling GetRemote: ... connect: connection refused.WARN [section-testimonials.html] couldn't fetch remote image ...and renders/default.png; the other testimonials still fetch and cache their realpbs.twimg.comavatars normally.Automated fix for failed run