{"record":{"id":"7f07970d5780c20d","repo":"vxcontrol/pentagi","slug":"error-executing-template-v-7f0797","errorCode":null,"errorMessage":"error executing template: %v","messagePattern":"error executing template: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/pkg/tools/searchers/firecrawl.go","lineNumber":339,"sourceCode":"\t\t\tURL:      res.resolvedURL(),\n\t\t\tMarkdown: markdown,\n\t\t})\n\t}\n\n\ttemplateContext := map[string]any{\n\t\t\"Query\":     query,\n\t\t\"MaxLength\": maxRawContentLength,\n\t\t\"Results\":   docs,\n\t}\n\n\ttmpl, err := template.New(\"summarize\").Parse(templateText)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error creating template: %v\", err)\n\t}\n\n\tvar buf bytes.Buffer\n\tif err := tmpl.Execute(&buf, templateContext); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error executing template: %v\", err)\n\t}\n\n\treturn buf.String(), nil\n}\n\nfunc (f *firecrawl) IsAvailable() bool {\n\treturn f.apiKey() != \"\"\n}\n\nfunc (f *firecrawl) apiKey() string {\n\tif f.cfg == nil {\n\t\treturn \"\"\n\t}\n\n\treturn f.cfg.FirecrawlAPIKey\n}\n\nfunc (f *firecrawl) searchURL() string {","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/firecrawl.go#L321-L357","documentation":"getSummarizePrompt returns 'error executing template: %v' when tmpl.Execute fails while rendering the summarize prompt. Execution fails at runtime if the data pipeline errors — most plausibly the Markdown string triggering a writer error (e.g. bytes.Buffer write failure) or a nil/missing field during range evaluation. buildFirecrawlResult catches this and falls back to raw content, so search results are still returned, just without an LLM summary.","triggerScenarios":"tmpl.Execute(&buf, templateContext) errors while ranging over .Results docs or writing {{.Markdown}}; practically only when the underlying writer fails or the data shape no longer matches the template (e.g. Results changed to a type without ID/Title/URL/Markdown fields).","commonSituations":"Refactor renames firecrawlPromptDoc fields without updating the template; template context map keys changed (e.g. 'Results' renamed); an enormous document causing buffer/memory pressure in constrained environments.","solutions":["Check the wrapped error text — map missing-field errors indicate a template/data mismatch to fix","Keep firecrawlPromptDoc field names (ID, Title, URL, Markdown) in sync with the template placeholders","Add a unit test executing getSummarizePrompt with sample results to catch drift","No user action needed: results are still returned via getContentFromResults fallback"],"exampleFix":"// before: template references removed field\ntitle=\"{{.PageTitle}}\"\n// after: keep template aligned with firecrawlPromptDoc\ntitle=\"{{.Title}}\"","handlingStrategy":"fallback","validationCode":"// verify template data matches expected fields before executing\nfor _, d := range docs {\n    if d.Markdown == \"\" { continue } // matches getSummarizePrompt's own filtering\n}","typeGuard":null,"tryCatchPattern":"prompt, err := f.getSummarizePrompt(query, result)\nif err != nil {\n    writer.WriteString(f.getContentFromResults(result.Data.Web)) // raw-content fallback\n} else { /* summarize */ }","preventionTips":["Keep firecrawlPromptDoc fields in sync with template placeholders via tests","Add a golden-file test of the rendered prompt to catch drift","Ensure buffer writes cannot fail unexpectedly by bounding document sizes (maxRawContentLength)"],"tags":["go","text-template","firecrawl","fallback"],"backgroundTag":"template-execution-error","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}