{"record":{"id":"64b6bf3e68be869e","repo":"gohugoio/hugo","slug":"failed-to-add-internal-partial-decorator-template","errorCode":null,"errorMessage":"failed to add internal partial decorator template %q: %w","messagePattern":"failed to add internal partial decorator template %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/tplimpl/templatetransform.go","lineNumber":354,"sourceCode":"\tinternalPartialName := fmt.Sprintf(\"_partials/%s%s\", PartialDecoratorPrefix, innerHash)\n\n\tif c.lookupFn(internalPartialName, c.t) == nil {\n\t\tinnerCopy := withNode.List.CopyList()\n\t\tti, err := c.store.addTransformedTemplateInsert(internalPartialName, SubCategoryInline)\n\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","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/tplimpl/templatetransform.go#L336-L372","documentation":"After inserting the decorator template info, Hugo sets its parse tree via store.addTransformedTemplateSetTree (templatetransform.go:352-355). If assigning the cloned inner node list to the template's tree fails, the error is wrapped with the internal decorator name. This is an internal step in synthesizing the partial decorator.","triggerScenarios":"Failure inside addTransformedTemplateSetTree when assigning the deferred/inner node list to the synthesized decorator template. Triggered during the transform of a with-partial block.","commonSituations":"Rare internal failure; may indicate a template-name collision or a parse-tree assignment problem in a custom Hugo build or an edge-case template.","solutions":["Inspect the wrapped error for the underlying cause.","Simplify the with-partial template to isolate the trigger.","Report as a Hugo bug with a reproducer if it occurs on stock Hugo.","Update Hugo."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Surface the wrapped cause during diagnosis:\nif err != nil && strings.Contains(err.Error(), \"failed to add internal partial decorator template\") {\n    log.Fatalf(\"decorator tree set failed: %v\", err)\n}","preventionTips":["Simplify with-partial blocks to isolate triggers.","Update Hugo.","Report persistent occurrences upstream."],"tags":["template","partial","decorator","internal","transform","build"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}