vitessio/vitess · error

panic(err) — error from partitions.ExecuteToHTML(st.Value)

Error message

panic(err) — error from partitions.ExecuteToHTML(st.Value)

What it means

SrvKeyspaceCacheStatus.StatusAsHTML renders the cached srvkeyspace partitions via a Go template (partitions.ExecuteToHTML). If template execution fails, it panics with the template error instead of returning it, because the debug/status HTML endpoint has no error return path. A panic here means the cached value does not match the template's expectations.

Source

Thrown at go/vt/srvtopo/status.go:148

{{ range .Partitions }}
&nbsp;<b>{{ .ServedType }}:</b>
{{ range .ShardReferences }}
&nbsp;{{ .Name }}
{{ end }}
<br>
{{ end }}
`))
)

// StatusAsHTML returns an HTML version of our status.
// It works best if there is data in the cache.
func (st *SrvKeyspaceCacheStatus) StatusAsHTML() safehtml.HTML {
	if st.Value == nil {
		return noData
	}
	html, err := partitions.ExecuteToHTML(st.Value)
	if err != nil {
		panic(err)
	}
	return html
}

// SrvKeyspaceCacheStatusList is used for sorting
type SrvKeyspaceCacheStatusList []*SrvKeyspaceCacheStatus

// Len is part of sort.Interface
func (skcsl SrvKeyspaceCacheStatusList) Len() int {
	return len(skcsl)
}

// Less is part of sort.Interface
func (skcsl SrvKeyspaceCacheStatusList) Less(i, j int) bool {
	return skcsl[i].Cell+"."+skcsl[i].Keyspace <
		skcsl[j].Cell+"."+skcsl[j].Keyspace
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Restart the vtgate/vttablet process so the srvkeyspace cache is repopulated by the current code version.
  2. Confirm all components are on the same Vitess version so the cached SrvKeyspacesPartitions shape matches the template.
  3. If reproducible, file a bug with the template error: the panic wraps the underlying ExecuteToHTML error which names the failing field.
Defensive patterns

Strategy: fallback

Try / catch

// StatusAsHTML has no error return; wrap the caller with a recover for the debug endpoint.
func safeStatusAsHTML(st *srvtopo.SrvKeyspaceCacheStatus) (out safehtml.HTML) {
  defer func() {
    if r := recover(); r != nil {
      out = safehtml.HTML(fmt.Sprintf("<pre>status render failed: %v</pre>", r))
    }
  }()
  return st.StatusAsHTML()
}

Prevention

When it happens

Trigger: Calling StatusAsHTML when st.Value holds a SrvKeyspacesPartitions object whose data violates the template contract (nil/missing fields the template dereferences, wrong dynamic type), causing ExecuteToHTML to return an error.

Common situations: Visiting the /srvkeyspace debug status page on a vttablet/vtgate whose srvkeyspace cache was populated by an older or newer Vitess version with a changed partition structure; partially initialized cache status served before the first update completed; hand-constructed values in tests.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/0499dc46775e3d97. Report an issue: GitHub.