Skip to content

Fix resource transformation chaining after content access - #15188

Merged
bep merged 1 commit into
gohugoio:masterfrom
bep:fix/cssbuildorderissue
Aug 10, 2026
Merged

Fix resource transformation chaining after content access#15188
bep merged 1 commit into
gohugoio:masterfrom
bep:fix/cssbuildorderissue

Conversation

@bep

@bep bep commented Aug 10, 2026

Copy link
Copy Markdown
Member

When a transformed resource had been initialized (e.g. via .Data, .Content
or .RelPermalink) before chaining another transformation, the new chain
would run on the transformed output instead of the original source,
re-running all transformations on their own output.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

When a transformed resource had been initialized (e.g. via .Data, .Content
or .RelPermalink) before chaining another transformation, the new chain
would run on the transformed output instead of the original source,
re-running all transformations on their own output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression/bug in Hugo’s resource transformation pipeline where reading a transformed resource’s content (e.g. via .Content, .Data, .RelPermalink) could mutate the adapter’s internal target such that subsequent chained transformations would incorrectly re-run starting from the already-transformed output (effectively applying prior transforms to their own output).

Changes:

  • Track the “source” (pre-chain) transformableResource on resourceAdapter and use it as the transformation starting point when appending new transformations.
  • Ensure cloned resources (cloneTo) also reset the tracked source target to the clone’s base target.
  • Add an integration test covering css.Build artifact generation followed by fingerprint chaining after content access, asserting stable hashes and output paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
resources/transform.go Introduces sourceTarget on resourceAdapter and uses it when starting a new transformation chain to prevent chaining from the already-transformed inner target.
tpl/css/build_integration_test.go Adds a regression test that reads built CSS content before chaining fingerprint, ensuring the full chain re-runs from the original source and produces the expected fingerprint/hash.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bep
bep merged commit f772998 into gohugoio:master Aug 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants