vxcontrol/pentagi · error
error creating template: %v
Error message
error creating template: %v
What it means
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.
Source
Thrown at backend/pkg/tools/searchers/firecrawl.go:334
}
markdown := res.Markdown[:min(len(res.Markdown), maxRawContentLength)]
docs = append(docs, firecrawlPromptDoc{
ID: i + 1,
Title: res.resolvedTitle(),
URL: res.resolvedURL(),
Markdown: markdown,
})
}
templateContext := map[string]any{
"Query": query,
"MaxLength": maxRawContentLength,
"Results": docs,
}
tmpl, err := template.New("summarize").Parse(templateText)
if err != nil {
return "", fmt.Errorf("error creating template: %v", err)
}
var buf bytes.Buffer
if err := tmpl.Execute(&buf, templateContext); err != nil {
return "", fmt.Errorf("error executing template: %v", err)
}
return buf.String(), nil
}
func (f *firecrawl) IsAvailable() bool {
return f.apiKey() != ""
}
func (f *firecrawl) apiKey() string {
if f.cfg == nil {
return ""
}View on GitHub (pinned to ea665308ba)
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
Example fix
// before: malformed template text
DATA:
- <raw_content> tags ... {{.Query
// after: balanced delimiters
USER QUERY: "{{.Query}}" Defensive patterns
Strategy: validation
Validate before calling
// compile-time guard: parse the template in a test
func TestSummarizeTemplateParses(t *testing.T) {
_, err := template.New("summarize").Parse(templateText)
if err != nil { t.Fatalf("template broken: %v", err) }
} Prevention
- 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
When it happens
Trigger: 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}}).
Common situations: 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.
Related errors
- error executing template: %v
- bearer scheme must be used
- token can't be empty
- token validation disabled with default salt
- token is invalid
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/d39ad2017456f13b.
Report an issue: GitHub.