Fix resource transformation chaining after content access - #15188
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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)
transformableResourceonresourceAdapterand 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.Buildartifact generation followed byfingerprintchaining 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.
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.
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