vitessio/vitess · warning
failed to execute logEntry template: %v
Error message
failed to execute logEntry template: %v
What it means
showThrottlerLog renders each throttler log entry through logEntryTemplate; if template execution returns an error it panics. As with the header template, this should be impossible in normal operation and indicates the template and the Result/ColorLevel data struct are out of sync, or the response writer failed.
Source
Thrown at go/vt/throttler/throttlerlogz.go:167
if stateGreater(r.NewState, state) {
state = r.NewState
}
var colorLevel string
switch state {
case stateIncreaseRate:
colorLevel = "low"
case stateDecreaseAndGuessRate:
colorLevel = "medium"
case stateEmergency:
colorLevel = "high"
}
data := struct {
Result
ColorLevel string
}{r, colorLevel}
if err := logEntryTemplate.Execute(w, data); err != nil {
panic(fmt.Sprintf("failed to execute logEntry template: %v", err))
}
}
logz.EndHTMLTable(w)
// Print footer.
count := len(results)
var d time.Duration
if count > 0 {
d = results[0].Now.Sub(results[count-1].Now)
}
if err := logFooterTemplate.Execute(w, map[string]any{
"Count": count,
"TimeSpan": fmt.Sprintf("%.1f", d.Minutes()),
}); err != nil {
panic(fmt.Sprintf("failed to execute logFooter template: %v", err))
}
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Align logEntryTemplate field references with the current Result struct
- For streaming write failures, log and abort the response instead of panicking
- Re-run throttlerlogz unit tests after any template or struct change
Example fix
// before
if err := logEntryTemplate.Execute(w, data); err != nil {
panic(fmt.Sprintf("failed to execute logEntry template: %v", err))
}
// after
if err := logEntryTemplate.Execute(w, data); err != nil {
log.Warnf("failed to execute logEntry template: %v", err)
return
} Defensive patterns
Strategy: try-catch
Validate before calling
// verify template parses at startup
if err := logEntryTemplate.Execute(io.Discard, struct{ Result; ColorLevel string }{}); err != nil {
return err
} Try / catch
defer func() {
if r := recover(); r != nil {
log.Errorf("throttlerlogz entry render panic: %v", r)
http.Error(w, "internal error", http.StatusInternalServerError)
}
}() Prevention
- Keep logEntryTemplate in sync with Result struct changes
- Test template rendering in unit tests
- Treat client disconnects as non-fatal in HTML handlers
When it happens
Trigger: Rendering /throttlerlogz when logEntryTemplate references fields missing from the anonymous struct{Result; ColorLevel string}, or the HTTP response write fails mid-stream (client disconnect).
Common situations: Forks/patches that changed Result fields without updating logEntryTemplate; client disconnection while streaming many entries.
Related errors
- failed to execute logHeader template: %v
- failed to Execute() template: %v
- failed to generate vtgate consul datacenter from template: %
- failed to parse vtgate FQDN template %s: %w
- failed to parse vtgate host address template %s: %w
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/59f6b435cf4e5a73.
Report an issue: GitHub.