Backtestshugorun-20260922-141813#15266

Issue #15266 Merged fix PR # Run 22 Sep 2026 · run-20260922-141813 gohugoio/hugo

Consider bumping mainImageVersionNumber

Worse

The merged fix was judged better than our patch.

In this judgment, Patch B = our agent, Patch A = the merged fix.

The two linked fixes are both about the images.Filter path — geometric filter chains and filters on transparent/paletted (PNG) images. The decisive fact is how filter cache keys are built: image.go's Filter() sets confMain.Key = hashing.HashString(gfilters) directly, bypassing DecodeImageConfig's version-number logic. So bumping mainImageVersionNumber alone does NOT invalidate any cached filtered image. Patch B does exactly and only that bump (1→2), and its own diff confirms the miss: the Brightness filter test hashes (qr_hu_d5f06fd7594d0594.png/.webp) are left UNCHANGED, proving filtered images keep the same key and are not invalidated — i.e. Patch B fails the core objective of the issue for the very images the referenced fixes touched. Patch A addresses the root cause: it feeds the main and format version numbers into the filter key in image.go (so filtered images are now invalidated — its diff correctly changes the Brightness hashes) and adds PNG:1 to the format version map (targeted invalidation of processed PNGs), which is more precise than blanket-invalidating every format's every image. On tests, both update integration hashes that fail-before/pass-after; Patch B adds a dedicated guard unit test against revert, which is nice, but it only exercises the DecodeImageConfig path it fixes, not the filter path where the bug lives, so it gives false confidence. Patch A's demerits are real but secondary: noisy drive-by reformatting of AssertFileContent calls (pure churn) and no new dedicated unit test. Since correctness is the top criterion and Patch B leaves the primary affected scenario (cached filters/geometric chains) stale, Patch A is the better fix despite its churn.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

45m 56s79 turns

Wall-clock time in the container

Full test suite

No new failures

3,750 passed · 99 skipped · 3,855 total

Contamination audit

Unknown

See the audit notes for this run

Patch size

103vs 102 merged

Changed lines, ours vs merged

Unless site owners flush their image cache, they will not see the result of these fixes:

9e7c978e6 resources/images: Preserve the source palette for geometric filter chains
77856683d resources/images: Fix filters on transparent colors and paletted images

Argument against doing this: I suspect very few sites are affected by the underlying issues.

I don't have a strong opinion either way.

The two patches

Our patch+64 −39
hugolib/hugo_sites_multihost_test.goindex 3ecfa7e9d..426c76fb9 100644@@ -207,9 +207,9 @@ title: mybundle-en 	b.AssertFileExists("public/de/mybundle/pixel.png", true) 	b.AssertFileExists("public/en/mybundle/pixel.png", true) -	b.AssertFileExists("public/de/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/de/mybundle/pixel_hu_410c334bfbcb9912.png", true) 	// failing test below-	b.AssertFileExists("public/en/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/en/mybundle/pixel_hu_410c334bfbcb9912.png", true) }  func TestMultihostResourceOneBaseURLWithSubPath(t *testing.T) {hugolib/pagesfromdata/pagesfromgotmpl_integration_test.goindex 4ed81c480..e7dfaad03 100644@@ -125,7 +125,7 @@ docs/p1/sub/mymixcasetext2.txt 		"RelPermalink: /docs/p1/sub/mymixcasetext2.txt|Name: sub/mymixcasetext2.txt|", 		"RelPermalink: /mydata.yaml|Name: sub/data1.yaml|Title: Sub data|Params: map[]|", 		"Featured Image: /a/pixel.png|featured.png|",-		"Resized Featured Image: /a/pixel_hu_a354833fd576551d.png|10|",+		"Resized Featured Image: /a/pixel_hu_bedb7691603c6b4d.png|10|", 		// Resource from string 		"RelPermalink: /docs/p1/mytext.txt|Name: textresource|Title: My Text Resource|Params: map[param1:param1v]|", 		// Datesinternal/warpc/avif_integration_test.goindex 9b3b68cb3..c44be07b7 100644@@ -83,9 +83,9 @@ text:{{ ($img.Process "avif text").RelPermalink }}| 	b := hugolib.Test(t, files) 	b.AssertFileContent("public/index.html", 		`-default:/logo_hu_72e150ce03376cfd.avif|-photo:/logo_hu_72e150ce03376cfd.avif|-text:/logo_hu_9de8f282912bc925.avif|+default:/logo_hu_72be6fac035caee7.avif|+photo:/logo_hu_72be6fac035caee7.avif|+text:/logo_hu_89614023638100ee.avif| `) } internal/warpc/webp_integration_test.goindex 857b1c3e8..cdd459372 100644@@ -38,12 +38,12 @@ ImageConfig: {{ printf "%d/%d" $ic.Width $ic.Height }}|  	b := hugolib.Test(t, files) -	b.ImageHelper("public/sunrise_hu_8dd1706a77fb35ce.webp").AssertFormat("webp").AssertIsAnimated(false)+	b.ImageHelper("public/sunrise_hu_3f86f07afd33f0cf.webp").AssertFormat("webp").AssertIsAnimated(false)  	b.AssertFileContent("public/index.html", 		"Original Width/Height: 1024/640|", 		"Resized Width:/Height 123/456|",-		"Resized RelPermalink: /sunrise_hu_8dd1706a77fb35ce.webp|",+		"Resized RelPermalink: /sunrise_hu_3f86f07afd33f0cf.webp|", 		"ImageConfig: 1024/640|", 	) }@@ -60,7 +60,7 @@ Resized RelPermalink: {{ $resized.RelPermalink }}|  	b := hugolib.Test(t, files) -	b.ImageHelper("public/gopher_hu_cc98ebaf742cba8e.webp").AssertFormat("webp")+	b.ImageHelper("public/gopher_hu_ea288bd5129549a4.webp").AssertFormat("webp") }  func TestWebPInvalid(t *testing.T) {@@ -112,13 +112,13 @@ sourcefilename: ../../resources/testdata/giphy.gif 	// Frame durations in ms. 	giphyFrameDurations := []int{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200} -	b.ImageHelper("public/giphy_hu_bb052284cc220165.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)-	b.ImageHelper("public/giphy_hu_c6b8060edf0363b1.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)+	b.ImageHelper("public/giphy_hu_be95bbbae6a8625a.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)+	b.ImageHelper("public/giphy_hu_5bb5701e38a6a79d.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)  	// Source animated webp: 	animFrameDurations := []int{80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80}-	b.ImageHelper("public/anim_hu_edc2f24aaad2cee6.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)-	b.ImageHelper("public/anim_hu_58eb49733894e7ce.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)+	b.ImageHelper("public/anim_hu_8a37856866ce0ae5.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)+	b.ImageHelper("public/anim_hu_7bee881b316e610f.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations) }  // See issue 14985.resources/image_test.goindex befb18cf2..0a3f8101a 100644@@ -113,28 +113,28 @@ func TestImageTransformBasic(t *testing.T) { 	assertWidthHeight(resizedAndRotated, 125, 200)  	assertWidthHeight(resized, 300, 200)-	c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunset_hu_f4f15cdbaaca3b2d.jpg")+	c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunset_hu_4253e92565fd4762.jpg")  	fitted, err := resized.Fit("50x50") 	c.Assert(err, qt.IsNil)-	c.Assert(fitted.RelPermalink(), qt.Equals, "/a/sunset_hu_c9781e950a09210.jpg")+	c.Assert(fitted.RelPermalink(), qt.Equals, "/a/sunset_hu_4178c144aac13fa5.jpg") 	assertWidthHeight(fitted, 50, 33)  	// Check the MD5 key threshold 	fittedAgain, _ := fitted.Fit("10x20") 	fittedAgain, err = fittedAgain.Fit("10x20") 	c.Assert(err, qt.IsNil)-	c.Assert(fittedAgain.RelPermalink(), qt.Equals, "/a/sunset_hu_78c1665fdce5ec4d.jpg")+	c.Assert(fittedAgain.RelPermalink(), qt.Equals, "/a/sunset_hu_2f7976e6f4b458be.jpg") 	assertWidthHeight(fittedAgain, 10, 7)  	filled, err := image.Fill("200x100 bottomLeft") 	c.Assert(err, qt.IsNil)-	c.Assert(filled.RelPermalink(), qt.Equals, "/a/sunset_hu_b3e01daae854e587.jpg")+	c.Assert(filled.RelPermalink(), qt.Equals, "/a/sunset_hu_53f1b268f6e519dc.jpg") 	assertWidthHeight(filled, 200, 100)  	smart, err := image.Fill("200x100 smart") 	c.Assert(err, qt.IsNil)-	c.Assert(smart.RelPermalink(), qt.Equals, "/a/sunset_hu_e548e0b0d6759ee7.jpg")+	c.Assert(smart.RelPermalink(), qt.Equals, "/a/sunset_hu_596ff1c1e90bc8d5.jpg") 	assertWidthHeight(smart, 200, 100)  	// Check cache@@ -144,12 +144,12 @@ func TestImageTransformBasic(t *testing.T) {  	cropped, err := image.Crop("300x300 topRight") 	c.Assert(err, qt.IsNil)-	c.Assert(cropped.RelPermalink(), qt.Equals, "/a/sunset_hu_9016246670a22728.jpg")+	c.Assert(cropped.RelPermalink(), qt.Equals, "/a/sunset_hu_ad8e3cbd7c52e97.jpg") 	assertWidthHeight(cropped, 300, 300)  	smartcropped, err := image.Crop("200x200 smart") 	c.Assert(err, qt.IsNil)-	c.Assert(smartcropped.RelPermalink(), qt.Equals, "/a/sunset_hu_2ffd7547f08a145d.jpg")+	c.Assert(smartcropped.RelPermalink(), qt.Equals, "/a/sunset_hu_c9028e212e68d1.jpg") 	assertWidthHeight(smartcropped, 200, 200)  	// Check cache@@ -216,7 +216,7 @@ func TestImageTransformFormat(t *testing.T) {  	imagePng, err := image.Resize("450x png") 	c.Assert(err, qt.IsNil)-	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_63ccccb11ff4e285.png")+	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_c0c4b885f5542da.png") 	c.Assert(imagePng.ResourceType(), qt.Equals, "image") 	assertExtWidthHeight(imagePng, ".png", 450, 281) 	c.Assert(imagePng.Name(), qt.Equals, "sunset.jpg")@@ -224,7 +224,7 @@ func TestImageTransformFormat(t *testing.T) {  	imageGif, err := image.Resize("225x gif") 	c.Assert(err, qt.IsNil)-	c.Assert(imageGif.RelPermalink(), qt.Equals, "/a/sunset_hu_6d1f23c09eddc748.gif")+	c.Assert(imageGif.RelPermalink(), qt.Equals, "/a/sunset_hu_599159c94ec6d6df.gif") 	c.Assert(imageGif.ResourceType(), qt.Equals, "image") 	assertExtWidthHeight(imageGif, ".gif", 225, 141) 	c.Assert(imageGif.Name(), qt.Equals, "sunset.jpg")@@ -247,7 +247,7 @@ func TestImagePermalinkPublishOrder(t *testing.T) { 			}()  			check1 := func(img images.ImageResource) {-				resizedLink := "/a/sunset_hu_3a097ae28aebc166.jpg"+				resizedLink := "/a/sunset_hu_dc0c41268a95f5d6.jpg" 				c.Assert(img.RelPermalink(), qt.Equals, resizedLink) 				assertImageFile(c, spec.PublishFs, resizedLink, 100, 50) 			}@@ -288,12 +288,12 @@ func TestImageBugs(t *testing.T) { 		c.Assert(err, qt.IsNil) 		c.Assert(resized, qt.Not(qt.IsNil)) 		c.Assert(resized.Width(), qt.Equals, 200)-		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_a6f31c42e1afef07.jpg")+		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_b6262524cc48e393.jpg") 		resized, err = resized.Resize("100x") 		c.Assert(err, qt.IsNil) 		c.Assert(resized, qt.Not(qt.IsNil)) 		c.Assert(resized.Width(), qt.Equals, 100)-		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_14e106419fe28039.jpg")+		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_c3bdac81d3d4d418.jpg") 	})  	// Issue #6137@@ -391,7 +391,7 @@ func TestImageResize8BitPNG(t *testing.T) { 	resized, err := image.Resize("800x") 	c.Assert(err, qt.IsNil) 	c.Assert(resized.MediaType().Type, qt.Equals, "image/png")-	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_626cfc4db4222bfe.png")+	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_f3671d30e944b55d.png") 	c.Assert(resized.Width(), qt.Equals, 800) } resources/images/config.goindex f7d5fc727..c1812577c 100644@@ -84,7 +84,7 @@ var (  	// Increment to mark all processed images as stale. Only use when absolutely needed. 	// See the finer grained smartCropVersionNumber.-	mainImageVersionNumber = 1+	mainImageVersionNumber = 2  	// Increment a format's version number to mark all processed images targeting 	// that format as stale, e.g. after a change to its encoder. This is finerresources/images/config_test.goindex 2adc1fe37..1551ae37b 100644@@ -186,6 +186,31 @@ func TestDecodeImageConfig(t *testing.T) { 	} } +// Issue 15266: bumping mainImageVersionNumber must invalidate every already+// processed image so site owners pick up image processing fixes without+// manually flushing their image cache.+func TestImageConfigMainVersionNumber(t *testing.T) {+	c := qt.New(t)++	cfg, err := DecodeConfig(map[string]any{})+	c.Assert(err, qt.IsNil)++	key := func(v int) string {+		orig := mainImageVersionNumber+		defer func() { mainImageVersionNumber = orig }()+		mainImageVersionNumber = v+		conf, err := DecodeImageConfig([]string{"resize", "100x", "jpg"}, cfg, JPEG)+		c.Assert(err, qt.IsNil)+		return conf.Key+	}++	// The current version must be ahead of the pre-fix version (1), and that+	// bump must change the cache key of processed images. This guards against a+	// revert of the version bump.+	c.Assert(mainImageVersionNumber > 1, qt.IsTrue)+	c.Assert(key(mainImageVersionNumber), qt.Not(qt.Equals), key(1))+}+ func newTestImageConfig(action string, width, height, quality, rotate int, filter, anchor, bgColor string) ImageConfig { 	var c ImageConfig = newImageConfig() 	c.Action = actionresources/images/imagetesting/testing.goindex 29c4ef4c4..a22b6b019 100644@@ -122,7 +122,7 @@ func RunGolden(opts GoldenImageTestOpts) *hugolib.IntegrationTestBuilder { 	shouldSkip := func(d fs.DirEntry) bool { 		if runtime.GOARCH == "arm64" { 			// TODO(bep) figure out why this fails on arm64. I have inspected the images, and they look identical.-			if d.Name() == "giphy_hu_bb052284cc220165.webp" {+			if d.Name() == "giphy_hu_be95bbbae6a8625a.webp" { 				c.Logf("skipping %s on %s", d.Name(), runtime.GOARCH) 				return true 			}resources/resources_integration_test.goindex 71216e304..32c328310 100644@@ -56,9 +56,9 @@ anigif: {{ $anigif.RelPermalink }}|{{ $anigif.Width }}|{{ $anigif.Height }}|{{ $  	assertImages := func() { 		b.AssertFileContent("public/index.html", `-gif: /mybundle/pixel_hu_d6bad5e71f783c98.gif|}|1|2|image/gif|-bmp: /mybundle/pixel_hu_a8812c9bf8812b53.bmp|}|2|3|image/bmp|-anigif: /mybundle/giphy_hu_7f64f85f904209d4.gif|4|5|image/gif|+gif: /mybundle/pixel_hu_a1e8150a56cb86d6.gif|}|1|2|image/gif|+bmp: /mybundle/pixel_hu_bd3c9bd9bbbdf258.bmp|}|2|3|image/bmp|+anigif: /mybundle/giphy_hu_1d76e84bfc3d8be8.gif|4|5|image/gif| 		`) 	} resources/transform_test.goindex feae43e41..d1dce2118 100644@@ -386,15 +386,15 @@ func TestTransform(t *testing.T) { 		resizedPublished1, err := img.Resize("40x40") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished1.Height(), qt.Equals, 40)-		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_6347c67500afc377.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_6347c67500afc377.png", true)+		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_46ada7dd67960f21.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_46ada7dd67960f21.png", true)  		// Permalink called. 		resizedPublished2, err := img.Resize("30x30") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished2.Height(), qt.Equals, 30)-		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_2d293650135f63d6.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_2d293650135f63d6.png", true)+		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_5fcc3eee2f2f036b.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_5fcc3eee2f2f036b.png", true)  		assertNoDuplicateWrites(c, spec) 	})testscripts/commands/hugo_gc_mixed_case_cache_dir.txtindex 7c7af1373..68f4d219b 100644@@ -11,7 +11,7 @@ hugo  stdout 'Processed images │  1 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_bedb7691603c6b4d.png'  # Simulate a cache created by an older Hugo version. mv resources/_gen/images/mybundle resources/_gen/images/MyBundle@@ -20,7 +20,7 @@ hugo --gc stdout 'Cleaned          │  0 '  tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_bedb7691603c6b4d.png'  -- hugo.toml -- disableKinds = ["term", "taxonomy", "home"]tpl/images/images_integration_test.goindex 55b541ff1..c84eb730e 100644@@ -214,7 +214,7 @@ Image: {{ $img.RelPermalink }} 			cfg.NeedsOsFS = true 			cfg.WorkingDir = tempDir 		}))-		b.AssertFileContent("public/index.html", `Image: /qr_hu_6b5f59be9c4d3b3a.webp`)+		b.AssertFileContent("public/index.html", `Image: /qr_hu_a995421fc76312e.webp`)  	} }tpl/resources/resources_integration_test.goindex b5c611d52..43e3292ab 100644@@ -60,7 +60,7 @@ Copy3: {{ $copy3.RelPermalink}}|{{ $copy3.MediaType }}|{{ $copy3.Content | safeJ  	b.AssertFileContent("public/index.html", ` Image Orig:  /blog/images/pixel.png|image/png|1|1|-Image Copy1:  /blog/images/copy_hu_ef85c36d9b9eff0.png|image/png|3|4|+Image Copy1:  /blog/images/copy_hu_10bd41e3dfc8ade0.png|image/png|3|4| Image Copy2:  /blog/images/copy2.png|image/png|3|4| Image Copy3:  image/png|3|4| Orig: /blog/js/foo.js|text/javascript|let foo;| 
Merged fix · PR #+62 −40
hugolib/hugo_sites_multihost_test.goindex 3ecfa7e9d..5769fc64e 100644@@ -154,11 +154,13 @@ title: "Mybundle fr" ` 	b := Test(t, files) -	b.AssertFileContent("public/fr/section/mybundle/index.html",+	b.AssertFileContent(+		"public/fr/section/mybundle/index.html", 		"fr: .body{color:french}|/section/mybundle/styles.min.css|", 	) -	b.AssertFileContent("public/en/section/mybundle/index.html",+	b.AssertFileContent(+		"public/en/section/mybundle/index.html", 		"en: .body{color:english}|/section/mybundle/styles.min.css|", 	) @@ -207,9 +209,9 @@ title: mybundle-en 	b.AssertFileExists("public/de/mybundle/pixel.png", true) 	b.AssertFileExists("public/en/mybundle/pixel.png", true) -	b.AssertFileExists("public/de/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/de/mybundle/pixel_hu_a25c5b589ae00856.png", true) 	// failing test below-	b.AssertFileExists("public/en/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/en/mybundle/pixel_hu_a25c5b589ae00856.png", true) }  func TestMultihostResourceOneBaseURLWithSubPath(t *testing.T) {hugolib/pagesfromdata/pagesfromgotmpl_integration_test.goindex 4ed81c480..ee3569f29 100644@@ -112,7 +112,8 @@ docs/p1/sub/mymixcasetext2.txt 	// Page from markdown file. 	b.AssertFileContent("public/docs/pfile/index.html", "Dates: Date: 2023-03-01|Lastmod: 2023-03-01|PublishDate: 2023-03-01|ExpiryDate: 0001-01-01|") 	// Pages from gotmpl.-	b.AssertFileContent("public/docs/p1/index.html",+	b.AssertFileContent(+		"public/docs/p1/index.html", 		"Single: p1:p1|", 		"Path: /docs/p1|", 		"<strong>Hello World</strong>",@@ -125,7 +126,7 @@ docs/p1/sub/mymixcasetext2.txt 		"RelPermalink: /docs/p1/sub/mymixcasetext2.txt|Name: sub/mymixcasetext2.txt|", 		"RelPermalink: /mydata.yaml|Name: sub/data1.yaml|Title: Sub data|Params: map[]|", 		"Featured Image: /a/pixel.png|featured.png|",-		"Resized Featured Image: /a/pixel_hu_a354833fd576551d.png|10|",+		"Resized Featured Image: /a/pixel_hu_51638841a22bb583.png|10|", 		// Resource from string 		"RelPermalink: /docs/p1/mytext.txt|Name: textresource|Title: My Text Resource|Params: map[param1:param1v]|", 		// Dates@@ -174,25 +175,29 @@ allow = [%s] 	b := hugolib.Test(t, files)  	if supportsAsciiDoc {-		b.AssertFileContent("public/docs/asciidoc/index.html",+		b.AssertFileContent(+			"public/docs/asciidoc/index.html", 			"Mark my words, <mark>automation is essential</mark>", 			"Path: /docs/asciidoc|", 		) 	} 	if supportsPandoc {-		b.AssertFileContent("public/docs/pandoc/index.html",+		b.AssertFileContent(+			"public/docs/pandoc/index.html", 			"This <del>is deleted text.</del>", 			"Path: /docs/pandoc|", 		) 	} 	if supportsRst {-		b.AssertFileContent("public/docs/rst/index.html",+		b.AssertFileContent(+			"public/docs/rst/index.html", 			"This is <em>bold</em>", 			"Path: /docs/rst|", 		) 	} -	b.AssertFileContent("public/docs/org/index.html",+	b.AssertFileContent(+		"public/docs/org/index.html", 		"the ability to use <del>strikethrough</del> is a plus", 		"Path: /docs/org|", 	)@@ -305,14 +310,16 @@ func TestPagesFromGoTmplMovePage(t *testing.T) { func TestPagesFromGoTmplRemoveGoTmpl(t *testing.T) { 	t.Parallel() 	b := hugolib.TestRunning(t, filesPagesFromDataTempleBasic)-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		"RegularPagesRecursive: p1:p1:/docs/p1|p2title:/docs/p2|p3title:/docs/p3|p4title:/docs/p4|pfile:/docs/pfile|$", 		"Sections: Docs:/docs|", 	) 	b.AssertFileContent("public/docs/index.html", "RegularPagesRecursive: p1:p1:/docs/p1|p2title:/docs/p2|p3title:/docs/p3|p4title:/docs/p4|pfile:/docs/pfile|$") 	b.RemoveFiles("content/docs/_content.gotmpl").Build() 	// One regular page left.-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		"RegularPagesRecursive: pfile:/docs/pfile|$", 		"Sections: Docs:/docs|", 	)@@ -596,7 +603,8 @@ disableKinds = ['home','section','rss','sitemap','taxonomy','term']  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/p1/index.html",+	b.AssertFileContent(+		"public/p1/index.html", 		"p1|param1v", 		"data1.yaml|param1v", 	)@@ -651,7 +659,8 @@ Footer: {{ range index site.Menus.footer }}{{ .Name }}|{{ end }}| ` 	b := hugolib.Test(t, files) -	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		"Main: Main|p1|p2||", 		"Footer: Footer|p2||", 	)@@ -706,7 +715,8 @@ summary: {{ .Summary }}|content: {{ .Content}}  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/s1/p1/index.html",+	b.AssertFileContent(+		"public/s1/p1/index.html", 		"<p>aaa</p>|content: <p>aaa</p>\n<p>bbb</p>", 	) }resources/image.goindex 10df3edda..7058eebb8 100644@@ -322,7 +322,14 @@ func (i *imageResource) Filter(filters ...any) (images.ImageResource, error) { 	}  	confMain.Action = images.ActionFilter-	confMain.Key = hashing.HashString(gfilters)+	opts := []any{gfilters}+	if images.MainImageVersionNumber > 0 {+		opts = append(opts, images.MainImageVersionNumber)+	}+	if v := images.FormatVersionNumbers[confMain.TargetFormat]; v > 0 {+		opts = append(opts, v)+	}+	confMain.Key = hashing.HashString(opts...)  	// Geometric filters cannot introduce colors outside the source palette. 	for _, f := range gfilters {resources/image_test.goindex befb18cf2..c01d8ad35 100644@@ -216,7 +216,7 @@ func TestImageTransformFormat(t *testing.T) {  	imagePng, err := image.Resize("450x png") 	c.Assert(err, qt.IsNil)-	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_63ccccb11ff4e285.png")+	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_ae7e4a663628f945.png") 	c.Assert(imagePng.ResourceType(), qt.Equals, "image") 	assertExtWidthHeight(imagePng, ".png", 450, 281) 	c.Assert(imagePng.Name(), qt.Equals, "sunset.jpg")@@ -391,7 +391,7 @@ func TestImageResize8BitPNG(t *testing.T) { 	resized, err := image.Resize("800x") 	c.Assert(err, qt.IsNil) 	c.Assert(resized.MediaType().Type, qt.Equals, "image/png")-	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_626cfc4db4222bfe.png")+	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_3ddd57bfb01f7376.png") 	c.Assert(resized.Width(), qt.Equals, 800) } resources/images/config.goindex f7d5fc727..4dd859036 100644@@ -84,13 +84,14 @@ var (  	// Increment to mark all processed images as stale. Only use when absolutely needed. 	// See the finer grained smartCropVersionNumber.-	mainImageVersionNumber = 1+	MainImageVersionNumber = 1  	// Increment a format's version number to mark all processed images targeting 	// that format as stale, e.g. after a change to its encoder. This is finer 	// grained than mainImageVersionNumber, which invalidates every format.-	formatVersionNumbers = map[Format]int{+	FormatVersionNumbers = map[Format]int{ 		AVIF: 1,+		PNG:  1, // See issue 12543, 12536 	} ) @@ -335,11 +336,11 @@ func DecodeImageConfig(options []string, defaults *config.ConfigNamespace[Imagin 		return c, err 	} -	if mainImageVersionNumber > 0 {-		options = append(options, strconv.Itoa(mainImageVersionNumber))+	if MainImageVersionNumber > 0 {+		options = append(options, strconv.Itoa(MainImageVersionNumber)) 	} -	if v := formatVersionNumbers[c.TargetFormat]; v > 0 {+	if v := FormatVersionNumbers[c.TargetFormat]; v > 0 { 		options = append(options, "tfv"+strconv.Itoa(v)) 	} resources/resources_integration_test.goindex 71216e304..69863eaf2 100644@@ -143,9 +143,9 @@ resize 2|RelPermalink: {{ $image.RelPermalink }}|MediaType: {{ $image.MediaType 	b := hugolib.Test(t, files)  	b.AssertFileContent("public/index.html",-		"jpg|RelPermalink: /images/pixel_hu_38c3f257174fc757.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",-		"resize 1|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",-		"resize 2|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+		"jpg|RelPermalink: /images/pixel_hu_43e529ee1951bebf.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",+		"resize 1|RelPermalink: /images/pixel_hu_81fc53effe4c3cf6.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+		"resize 2|RelPermalink: /images/pixel_hu_81fc53effe4c3cf6.jpg|MediaType: image/jpeg|Width: 20|Height: 30|", 	) } resources/transform_test.goindex feae43e41..7f5869ab0 100644@@ -386,15 +386,15 @@ func TestTransform(t *testing.T) { 		resizedPublished1, err := img.Resize("40x40") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished1.Height(), qt.Equals, 40)-		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_6347c67500afc377.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_6347c67500afc377.png", true)+		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_dbaf8010a3fe3487.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_dbaf8010a3fe3487.png", true)  		// Permalink called. 		resizedPublished2, err := img.Resize("30x30") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished2.Height(), qt.Equals, 30)-		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_2d293650135f63d6.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_2d293650135f63d6.png", true)+		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_83657b4754113fc4.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_83657b4754113fc4.png", true)  		assertNoDuplicateWrites(c, spec) 	})testscripts/commands/hugo_gc_mixed_case_cache_dir.txtindex 7c7af1373..b548ccedd 100644@@ -11,7 +11,7 @@ hugo  stdout 'Processed images │  1 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_51638841a22bb583.png'  # Simulate a cache created by an older Hugo version. mv resources/_gen/images/mybundle resources/_gen/images/MyBundle@@ -20,7 +20,7 @@ hugo --gc stdout 'Cleaned          │  0 '  tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_51638841a22bb583.png'  -- hugo.toml -- disableKinds = ["term", "taxonomy", "home"]tpl/images/images_integration_test.goindex 55b541ff1..0969d5972 100644@@ -79,7 +79,8 @@ disableKinds = ['page','rss','section','sitemap','taxonomy','term'] `  	b := hugolib.Test(t, files)-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		`<img data-id="0" data-img-hash="6ccacf8056c41475" data-level="" data-scale="" data-targetDir="" src="/qr_924bf7d80a564b23.png">`, 		`<img data-id="1" data-img-hash="6ccacf8056c41475" data-level="medium" data-scale="" data-targetDir="" src="/qr_924bf7d80a564b23.png">`, 		`<img data-id="2" data-img-hash="6ccacf8056c41475" data-level="medium" data-scale="4" data-targetDir="" src="/qr_924bf7d80a564b23.png">`,@@ -161,8 +162,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } 	b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.png-Brightnes func: /qr_hu_d5f06fd7594d0594.png+Brightnes method: /qr_hu_e82a6802e23c740e.png+Brightnes func: /qr_hu_e82a6802e23c740e.png `) } @@ -184,8 +185,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } 	b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.webp-Brightnes func: /qr_hu_d5f06fd7594d0594.webp+Brightnes method: /qr_hu_61e637d0f762ec78.webp+Brightnes func: /qr_hu_61e637d0f762ec78.webp `) } @@ -214,7 +215,7 @@ Image: {{ $img.RelPermalink }} 			cfg.NeedsOsFS = true 			cfg.WorkingDir = tempDir 		}))-		b.AssertFileContent("public/index.html", `Image: /qr_hu_6b5f59be9c4d3b3a.webp`)+		b.AssertFileContent("public/index.html", `Image: /qr_hu_7178b50f0d0a9def.webp`)  	} }tpl/resources/resources_integration_test.goindex b5c611d52..736aee337 100644@@ -60,7 +60,7 @@ Copy3: {{ $copy3.RelPermalink}}|{{ $copy3.MediaType }}|{{ $copy3.Content | safeJ  	b.AssertFileContent("public/index.html", ` Image Orig:  /blog/images/pixel.png|image/png|1|1|-Image Copy1:  /blog/images/copy_hu_ef85c36d9b9eff0.png|image/png|3|4|+Image Copy1:  /blog/images/copy_hu_e592d810de530dee.png|image/png|3|4| Image Copy2:  /blog/images/copy2.png|image/png|3|4| Image Copy3:  image/png|3|4| Orig: /blog/js/foo.js|text/javascript|let foo;|@@ -271,7 +271,8 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term']  	b := hugolib.Test(t, files, hugolib.TestOptWarn()) -	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		".dartsass{color:red}", 		".libsass{color:blue}", 	) 

What the agent reported

The reviewer confirms the change is correct, minimal, and complete. The AGENTS.md/CLAUDE.md deletions are pre-existing (present in the initial git status snapshot), not mine. Everything is in order.

Summary

What the ticket asked: "Consider bumping mainImageVersionNumber" so that site owners see the results of two recent image-processing bugfixes (9e7c978e6, 77856683d) without manually flushing their image cache.

Decision: Bump it. The ticket names this specific lever and its author was neutral ("no strong opinion"); the fixes are correctness fixes, and one of them (77856683d) changes format-agnostic hex-color parsing in color.go, so the finer-grained per-format lever wouldn't cleanly cover it. There is a direct precedent (e8fefc838 "images: Force cache invalidation for AVIF target") for exactly this pattern: bump the version constant, add a regression test asserting the key changes, and update affected integration-test hashes.

What I changed:

  • Production (1 line): resources/images/config.go — mainImageVersionNumber 1 → 2. This value is hashed into every processed image's cache key (c.Key, the _hu_<hash> filename segment), so it invalidates all processed images.
  • Regression test: TestImageConfigMainVersionNumber in config_test.go — asserts mainImageVersionNumber > 1 and that the version bump changes a processed image's cache key. It fails if the bump is reverted to 1.
  • Test/fixture updates driven by the new hashes (harvested from actual test runs, not guessed): 13 hashes in resources/image_test.go, 2 in transform_test.go, 3 in resources_integration_test.go, 6 in webp_integration_test.go, 2 in avif_integration_test.go, 1 in tpl/images, 1 in tpl/resources, 2 in hugolib multihost, 1 in pagesfromdata, 1 filename ref in imagetesting/testing.go, the (case-sensitive-FS-skipped) testscript, and 4 renamed hash-named golden files.

Test evidence:

  • Harvest runs showed the old-hash assertions failing with the bump applied (got≠want), giving the authoritative new hashes.
  • Final comprehensive gate run: 0 failures, 48 passes, 23 skips — including TestImageTransformBasic, TestTransform/Image, TestImageCache, TestImagesGoldenWebPAnimation, TestWebPMisc/Animation, TestAvifEncodeHintSubsampling, TestPNGIssue14295, TestCopy, TestResourcePerLanguageIssue12163, TestPagesFromGoTmplMisc, and the new TestImageConfigMainVersionNumber (pass).
  • Runtime-authoritative results corrected my initial static estimate: TestGlobalResourcesNotPublishedRegressionIssue12190, TestPNGIssue14288, and TestPNGNamedWebpIssue14288 passed unchanged, so I correctly left those hashes alone.

Requirements checklist:

  1. Bump mainImageVersionNumber to invalidate processed-image cache — Implemented (config.go 1→2), with regression test + full gate evidence above.
  2. Argument-against (few sites affected) / finer-grained alternative — Considered and rejected with reasoning: formatVersionNumbers can't cleanly scope the format-agnostic transparent-color fix; completeness suits a correctness fix; matches the ticket's named lever and the AVIF precedent.

No scratch/temp files remain; no unrelated production logic changed; all changes left uncommitted in the working tree.