Skip to content

fix(image): name the page a missing image was referenced from - #2153

Merged
markdumay merged 3 commits into
mainfrom
fix/missing-image-diagnostics
Sep 3, 2026
Merged

fix(image): name the page a missing image was referenced from#2153
markdumay merged 3 commits into
mainfrom
fix/missing-image-diagnostics

Conversation

@markdumay

Copy link
Copy Markdown
Collaborator

A missing vector image was reported with a bare warnf carrying only the src:

WARN  Cannot find vector image resource: "/img/foo.svg"

On a site of any size that is not actionable — the log says a file is missing and nothing says which page referenced it, so finding the offending shortcode means grepping content by hand. It also has no warning id, so it cannot be suppressed with ignoreLogs the way every other Hinode warning can.

Both diagnostics now route through LogMsg, exactly as the invalid-arguments case a few lines above already does:

WARN  partial [assets/helpers/image-dimension.html] - Cannot find vector image resource: my-page.md
	src: "/img/foo.svg"
	searched: assets and static
You can suppress this warning by adding the following to your project configuration:
ignoreLogs = [`warn-missing-image`]

params.debugging.failOnMissingImage

New, defaulting to false — no existing site changes behavior. Referencing an image supplied outside the build (a CDN path, a deploy-time asset) is legitimate, so making this fatal by default would break working sites on upgrade.

gethinode/mod-utils#367 reads the same flag for raster images, so the setting means one thing across both repos. That PR should land and release first; the vector half of this one works independently of it.

Scope notes

  • The unsupported-media-type case reuses GetImage's existing warn-unsupported-image id rather than inventing a second one, so a single ignoreLogs entry covers both. It is never escalated by failOnMissingImage: the file resolves, so it is a content error, not a missing asset.
  • Raster images already had page context via GetImage — I initially added a second report for them and removed it after the build showed my branch never fired. This PR does not touch that path.

Verification

exampleSite, with a probe page carrying a missing plain SVG, a missing mode="true" pair, and a missing raster:

before after
diagnostic WARN Cannot find vector image resource: "<src>" names the page, the src, and the id
suppressible no id ignoreLogs = [warn-missing-image]
mode="true" pair reports both expanded filenames, not one
failOnMissingImage set n/a ERROR ×4, exit 1
failOnMissingImage unset exit 0 exit 0, warnings only

The mode-pair result is worth calling out: both -light and -dark are reported, so no extra call site is needed in the expansion path.

🤖 Generated with Claude Code

A missing vector image was reported with a bare warnf carrying only the
src. On a site of any size that is not actionable: the log says a file is
missing and nothing says which page referenced it, so finding the offending
shortcode means grepping content by hand.

Routes both diagnostics through LogMsg, as the invalid-arguments case in
this partial already does. Each now carries the partial, the page, the src,
and a warning id — so Hugo prints the ignoreLogs line that suppresses it,
and a site can silence one class without silencing the rest.

Registers params.debugging.failOnMissingImage, which escalates the missing
case to a build failure. Defaults to false, so no existing site changes
behavior; referencing an image supplied outside the build is legitimate.
mod-utils GetImage reads the same flag for raster images, so the setting
means one thing across both.

The unsupported-media-type case reuses GetImage's existing
warn-unsupported-image id rather than inventing a second one, and is never
escalated: the file resolves, so it is a content error rather than a
missing asset.

Verified against exampleSite. Before, three broken references produced
`WARN Cannot find vector image resource: "<src>"` with no page and no id;
after, each names zz-missing-image-probe.md and prints its ignoreLogs
hint. A mode="true" pair reports both expanded filenames, not one. With
failOnMissingImage set the build exits 1; unset it exits 0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Sep 3, 2026

Copy link
Copy Markdown

Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit 281a9d3
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6a9954a854ee4c000805de73
😎 Deploy Preview https://deploy-preview-2153--gethinode-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

markdumay and others added 2 commits September 3, 2026 11:54
v6.12.0 is the release of gethinode/mod-utils#367, which reads the same
params.debugging.failOnMissingImage flag registered here and applies it to
raster images. Pinning it makes the setting mean one thing across both
paths rather than failing the build for vector sources only.

Verified against the released module rather than the local replace used
while developing the pair: with the flag set, a missing SVG and a missing
raster now report ERROR from image-dimension.html and GetImage.html
respectively and the build exits 1; unset, exampleSite builds clean at
exit 0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@markdumay
markdumay enabled auto-merge September 3, 2026 11:06
@markdumay
markdumay merged commit be5a53d into main Sep 3, 2026
17 checks passed
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 3.23.10 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@markdumay
markdumay deleted the fix/missing-image-diagnostics branch September 3, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant