{"record":{"id":"3161890f31fb23e1","repo":"gohugoio/hugo","slug":"deferred-execution-with-id-q-not-found","errorCode":null,"errorMessage":"deferred execution with id %q not found","messagePattern":"deferred execution with id %q not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hugolib/hugo_sites_build.go","lineNumber":547,"sourceCode":"\t\tfor {\n\t\t\tif k >= len(content) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tl := bytes.Index(content[k:], []byte(tpl.HugoDeferredTemplatePrefix))\n\t\t\tif l == -1 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tm := bytes.Index(content[k+l:], []byte(tpl.HugoDeferredTemplateSuffix)) + len(tpl.HugoDeferredTemplateSuffix)\n\n\t\t\tlow, high := k+l, k+l+m\n\n\t\t\tforward := l + m\n\t\t\tid := string(content[low:high])\n\n\t\t\tif err := func() error {\n\t\t\t\tdeferred, found := de.Executions.Get(id)\n\t\t\t\tif !found {\n\t\t\t\t\tpanic(fmt.Sprintf(\"deferred execution with id %q not found\", id))\n\t\t\t\t}\n\t\t\t\tdeferred.Mu.Lock()\n\t\t\t\tdefer deferred.Mu.Unlock()\n\n\t\t\t\tif !deferred.Executed {\n\t\t\t\t\ttmpl := s.Deps.GetTemplateStore()\n\t\t\t\t\tti := s.TemplateStore.LookupByPath(deferred.TemplatePath)\n\t\t\t\t\tif ti == nil {\n\t\t\t\t\t\tpanic(fmt.Sprintf(\"template %q not found\", deferred.TemplatePath))\n\t\t\t\t\t}\n\n\t\t\t\t\tif err := func() error {\n\t\t\t\t\t\tbuf := bufferpool.GetBuffer()\n\t\t\t\t\t\tdefer bufferpool.PutBuffer(buf)\n\n\t\t\t\t\t\terr = tmpl.ExecuteWithContext(deferred.Ctx, ti, buf, deferred.Data)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/hugo_sites_build.go#L529-L565","documentation":"Panic during post-publish content rewriting when a deferred-template marker found in rendered output has an ID that is absent from the de.Executions map. Hugo inserts deferred template fragments during rendering and resolves them after the main publish pass; an unknown ID means the bookkeeping that registers deferred executions drifted out of sync with the markers written into the content. The code comment around it implies this should never happen under normal operation, marking it an internal bug.","triggerScenarios":"A template uses the Hugo deferred-template mechanism (deferred templates / partials evaluated late) and the registered Execution set is mutated or cleared between the render pass and the post-publish resolution pass. Concurrent/parallel rendering mutating the shared de.Executions map, or a custom output format that reorders the publish pipeline. Typically only seen with non-standard or partially-broken template constructs.","commonSituations":"Hugo version upgrade that changed the deferred-template protocol while stale incremental-build state lingers. A bug in a custom output format or render hook. A corrupted incremental build cache (run a clean build). A race in a fork that altered the deferred execution registry.","solutions":["Run a clean build (remove the Hugo project cache / resources/_gen and the build lock) to eliminate stale incremental state.","Update Hugo to the latest patch release; this is almost always an internal bookkeeping bug.","Identify the template using deferred execution and simplify it; file a Hugo issue with the template and the offending ID.","If you forked Hugo, audit concurrent access to the de.Executions map during the render+post-publish sequence."],"exampleFix":"# before: incremental build hits the panic\nhugo\n\n# after: purge cache and rebuild\nrm -rf public resources/_gen .hugo_build.lock && hugo --cleanDestinationDir","handlingStrategy":"validation","validationCode":"// Not directly preventable by an API user — it is an internal invariant.\n// Mitigate by running a clean build when incremental state is suspect:\n//   rm -rf public resources/_gen .hugo_build.lock && hugo\n// In embedded use, call Build with config.NoBuildLock=false only when state is fresh.","typeGuard":null,"tryCatchPattern":"// Go panics can be recovered, but only do this to surface a friendly error:\nfunc safeBuild(h *hugolib.HugoSites, cfg config.BuildCfg) (err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"hugo build panicked: %v\", r)\n        }\n    }()\n    return h.Build(cfg)\n}","preventionTips":["Clean the build cache when you see deferred-template panics.","Keep Hugo updated to pick up fixes to the deferred execution registry.","Avoid forking the deferred-template lifecycle.","If using custom output formats, test them against a clean build."],"tags":["deferred-template","post-publish","build","panic","internal-invariant"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}