Backtestshugorun-20260930-140149#15266

Issue #15266 Merged fix PR # Run 30 Sep 2026 · run-20260930-140149 gohugoio/hugo

Consider bumping mainImageVersionNumber

Error

The harness couldn't finish this ticket.

The solver produced no patch.. No judgment was produced for this ticket. It counts as an error in the run total.

Solve

18m 21s18 turns

Wall-clock time in the container

Full test suite

Not run

The harness did not reach the test stage

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

0vs 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+0 −0
No patch was produced.
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

I left the working tree unchanged: bumping mainImageVersionNumber wouldn't reach the images these two fixes change. I also couldn't run any tests here, so the one worthwhile change isn't applied.

Why the bump wouldn't help

  • The main version number only goes into ImageConfig.Key, which DecodeImageConfig builds (resources/images/config.go:338-340).
  • .Filter then replaces that key with its own: confMain.Key = hashing.HashString(gfilters) (resources/image.go:325). So filtered images never include the main version number.
  • Both commits only change .Filter output:
  • 77856683d: the palette skip applies to ActionFilter only, and the hex-color parsing change only affects colors that aren't fully opaque, as used by filters like images.Padding. Fully opaque colors produce the same result as before.
  • 9e7c978e6: this only changes the behaviour of filter chains.
  • Bumping it would invalidate every resized, cropped, fitted and filled image on every site, none of which changed. It would still leave the stale filtered images in place.

What would work: a filter-only version number, like the existing smartCropVersionNumber and formatVersionNumbers:

// resources/images/config.go, in the version var block
FilterVersionNumber = 1

// resources/image.go, Filter()
if images.FilterVersionNumber > 0 {
	confMain.Key = hashing.HashString(gfilters, images.FilterVersionNumber)
} else {
	confMain.Key = hashing.HashString(gfilters)
}

I had this implemented, then reverted it:

  • Tests can't run here. Module downloads are blocked, so ./bt-test fails at build setup ([setup failed]), even on the unmodified tree. I couldn't compile the change or see any test pass.
  • Three pinned filter filenames would change. They are in tpl/images/images_integration_test.go: lines 164-165 (qr_hu_d5f06fd7594d0594.png), 187-188 (.webp) and 217 (qr_hu_6b5f59be9c4d3b3a.webp). The new values come from gohugoio/hashstructure, which isn't available offline, so I couldn't work them out. Shipping the change would leave those tests failing.

On the "few sites are affected" argument: a filter-only bump is cheap, because it only re-processes filtered images. If you want it, apply the snippet above, run go test ./tpl/images/ ./resources/... and update those three expected filenames. That run is also the regression evidence.

Requirements

  1. Bump mainImageVersionNumber: not done. It wouldn't invalidate the affected images (evidence above) and would invalidate every other processed image.
  2. Make site owners see the fixes without flushing their cache: not done. The right fix is FilterVersionNumber above, but it can't be tested here, so there's no test in the diff.
  3. Weigh "very few sites affected": the smaller filter-only bump makes this concern mostly moot.

The AGENTS.md and CLAUDE.md deletions were already in the working tree when I started, and I left them alone.