{"record":{"id":"f11f76bf67d6bc41","repo":"gohugoio/hugo","slug":"failed-to-transform-internal-partial-decorator-tem","errorCode":null,"errorMessage":"failed to transform internal partial decorator template %q: %w","messagePattern":"failed to transform internal partial decorator template %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/tplimpl/templatetransform.go","lineNumber":359,"sourceCode":"\t\tif err != nil {\n\t\t\tc.err = fmt.Errorf(\"failed to create internal partial decorator template %q: %w\", internalPartialName, err)\n\t\t\treturn\n\t\t}\n\t\tif ti == nil {\n\t\t\tc.err = fmt.Errorf(\"failed to find internal partial decorator template %q after insertion\", internalPartialName)\n\t\t\treturn\n\t\t}\n\n\t\tcc := newTemplateTransformContext(ti, c.store, c.lookupFn)\n\n\t\ttree, err := c.store.addTransformedTemplateSetTree(ti, innerCopy)\n\t\tif err != nil {\n\t\t\tc.err = fmt.Errorf(\"failed to add internal partial decorator template %q: %w\", internalPartialName, err)\n\t\t\treturn\n\t\t}\n\n\t\tif err := cc.applyTransformationsAndSetReturnWrapper(tree); err != nil {\n\t\t\tc.err = fmt.Errorf(\"failed to transform internal partial decorator template %q: %w\", internalPartialName, err)\n\t\t\treturn\n\t\t}\n\n\t}\n\n\tnewInner := popPartialDecorator.CopyList()\n\tifNode := newInner.Nodes[0].(*parse.IfNode)\n\n\tplaceholderPipe := ifNode.Pipe.Cmds[0].Args[0].(*parse.PipeNode)\n\n\t// Set PLACEHOLDER1 to the unique ID for this partial decorator.\n\tsn1 := placeholderPipe.Cmds[0].Args[1].(*parse.PipeNode).Cmds[0].Args[0].(*parse.StringNode)\n\tsn1.Text = innerHash\n\tsn1.Quoted = fmt.Sprintf(\"%q\", sn1.Text)\n\n\tifNode.ElseList = withNode.List.CopyList()\n\n\tnewPipe := pushPartialDecorator.CopyList()","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/tplimpl/templatetransform.go#L341-L377","documentation":"Once the internal partial decorator template is created and its tree set, Hugo recursively runs the AST transformer on it (cc.applyTransformationsAndSetReturnWrapper, templatetransform.go:358-360). If that recursive transform fails, the error is wrapped with the decorator name. This catches nested transform errors in the synthesized template.","triggerScenarios":"The synthesized decorator template's inner content contains constructs that themselves fail transformation (e.g. nested unsupported inner usage or bad config). The recursive transform surfaces the failure.","commonSituations":"Complex with-partial blocks whose body contains additional constructs the transformer rejects; deep nesting of partial decorators; Hugo version regressions in recursive transform handling.","solutions":["Read the wrapped error from the recursive applyTransformationsAndSetReturnWrapper.","Simplify the body of the with-partial block to find the offending nested construct.","Update Hugo to the latest release.","Report with a minimal reproducer if it reproduces on stock Hugo."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Unwrap the recursive transform error:\nif err != nil && strings.Contains(err.Error(), \"failed to transform internal partial decorator\") {\n    log.Fatalf(\"recursive decorator transform failed: %v\", err)\n}","preventionTips":["Avoid deeply nested or complex constructs inside with-partial bodies.","Read the wrapped error to find the nested failure.","Update Hugo for transform-pass fixes."],"tags":["template","partial","decorator","internal","transform","recursion","build"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}