{"record":{"id":"82dfc9b44c8c04c9","repo":"gohugoio/hugo","slug":"failed-to-create-internal-partial-decorator-templa","errorCode":null,"errorMessage":"failed to create internal partial decorator template %q: %w","messagePattern":"failed to create internal partial decorator template %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/tplimpl/templatetransform.go","lineNumber":342,"sourceCode":"func (c *templateTransformContext) handleWithPartial(withNode *parse.WithNode) {\n\twithNodeInnerString := withNode.List.String()\n\tif templatesInnerRe.MatchString(withNodeInnerString) {\n\t\tc.err = fmt.Errorf(\"inner cannot be used inside a with block that wraps a partial decorator\")\n\t\treturn\n\t}\n\n\t// See #14333. That is a very odd construct, but we need to guard against it.\n\tif c.hasBreakOrContinueOutsideRange(withNode.List) {\n\t\treturn\n\t}\n\tinnerHash := hashing.XxHashFromStringHexEncoded(c.t.Name() + withNodeInnerString)\n\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","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/tplimpl/templatetransform.go#L324-L360","documentation":"While creating an internal partial decorator for a {{ with partial ... }} block, Hugo calls store.addTransformedTemplateInsert to register the synthesized template under _partials/_internal/decorator_<hash> (templatetransform.go:340-343). If that insertion returns an error, it is wrapped with the internal template name. This is an internal failure during the decorator-synthesis step.","triggerScenarios":"A failure inside addTransformedTemplateInsert when registering the synthesized decorator template — typically a deeper internal error in the template store (e.g. key collision, descriptor extraction failure). Triggered during the transform pass for a with-partial construct.","commonSituations":"Rare; usually indicates a Hugo internal bug or an extremely unusual template structure that exercises an unhandled path in template insertion. May appear during Hugo development or with edge-case template patterns.","solutions":["Read the wrapped error for the root cause from addTransformedTemplateInsert.","Simplify the with-partial block to see if the error disappears, then re-add constructs incrementally.","Report as a Hugo bug with the template and Hugo version if it reproduces on clean Hugo.","Update to the latest Hugo release."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Internal error — surface the wrapped cause in tests:\nif err != nil && strings.Contains(err.Error(), \"failed to create internal partial decorator\") {\n    t.Fatalf(\"internal decorator creation failed: %v\", err)\n}","preventionTips":["Keep with-partial blocks simple to avoid hitting internal edge cases.","Update Hugo to get decorator-synthesis fixes.","Report reproducible cases 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-14T00:17:10.932Z"}