vxcontrol/pentagi · warning

error executing template: %v

Error message

error executing template: %v

What it means

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.

Source

Thrown at backend/pkg/tools/searchers/firecrawl.go:339

			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 ""
	}

	return f.cfg.FirecrawlAPIKey
}

func (f *firecrawl) searchURL() string {

View on GitHub (pinned to ea665308ba)

Solutions

  1. Check the wrapped error text — map missing-field errors indicate a template/data mismatch to fix
  2. Keep firecrawlPromptDoc field names (ID, Title, URL, Markdown) in sync with the template placeholders
  3. Add a unit test executing getSummarizePrompt with sample results to catch drift
  4. No user action needed: results are still returned via getContentFromResults fallback

Example fix

// before: template references removed field
title="{{.PageTitle}}"
// after: keep template aligned with firecrawlPromptDoc
title="{{.Title}}"
Defensive patterns

Strategy: fallback

Validate before calling

// verify template data matches expected fields before executing
for _, d := range docs {
    if d.Markdown == "" { continue } // matches getSummarizePrompt's own filtering
}

Try / catch

prompt, err := f.getSummarizePrompt(query, result)
if err != nil {
    writer.WriteString(f.getContentFromResults(result.Data.Web)) // raw-content fallback
} else { /* summarize */ }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/7f07970d5780c20d. Report an issue: GitHub.