{"record":{"id":"d39ad2017456f13b","repo":"vxcontrol/pentagi","slug":"error-creating-template-v-d39ad2","errorCode":null,"errorMessage":"error creating template: %v","messagePattern":"error creating template: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/searchers/firecrawl.go","lineNumber":334,"sourceCode":"\t\t}\n\t\tmarkdown := res.Markdown[:min(len(res.Markdown), maxRawContentLength)]\n\t\tdocs = append(docs, firecrawlPromptDoc{\n\t\t\tID:       i + 1,\n\t\t\tTitle:    res.resolvedTitle(),\n\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}","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/firecrawl.go#L316-L352","documentation":"getSummarizePrompt builds a text/template for the LLM summarizer and returns 'error creating template: %v' when template.Parse fails. The template text is a compile-time constant in this file, so in practice Parse should never fail; the error exists as a guard. Callers (buildFirecrawlResult) degrade gracefully and emit raw markdown content instead of a summary.","triggerScenarios":"template.New(\"summarize\").Parse(templateText) returns an error — only possible if the embedded templateText constant is edited with malformed syntax (unbalanced {{ }}, bad pipeline, unknown function like {{.Foo | nosuchfunc}}).","commonSituations":"A developer edits the prompt template and introduces invalid template syntax; someone registers a custom template func that isn't added to FuncMap; refactoring moves templateText into config and the config value is malformed.","solutions":["Fix the template syntax reported in the wrapped error (check the line/column in the parse error message)","Validate the template in a unit test so parse failures are caught at CI time, not at runtime","If templateText becomes configurable, validate it at startup, not per request","No operational action needed if code is unmodified — this branch indicates a code bug, not a runtime condition"],"exampleFix":"// before: malformed template text\nDATA:\n- <raw_content> tags ... {{.Query\n// after: balanced delimiters\nUSER QUERY: \"{{.Query}}\"","handlingStrategy":"validation","validationCode":"// compile-time guard: parse the template in a test\nfunc TestSummarizeTemplateParses(t *testing.T) {\n    _, err := template.New(\"summarize\").Parse(templateText)\n    if err != nil { t.Fatalf(\"template broken: %v\", err) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a unit test that parses the embedded template on every CI run","Validate configurable template text at startup, not per request","Treat any occurrence of this error at runtime as a code bug, not an operational event"],"tags":["go","text-template","firecrawl","bug"],"backgroundTag":"template-parse-error","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}