yudai/gotty · error

failed to parse window title format `%s`

Error message

failed to parse window title format `%s`

What it means

Wrapped noesctmpl parse error in Server.New: the --title-format template string is syntactically invalid (unclosed delimiters, bad verbs), so the window-title template cannot be compiled at startup. Distinguished from the sibling index template, which panics because it is embedded and always valid.

Source

Thrown at server/server.go:57

	indexData, err := Asset("static/index.html")
	if err != nil {
		panic("index not found") // must be in bindata
	}
	if options.IndexFile != "" {
		path := homedir.Expand(options.IndexFile)
		indexData, err = ioutil.ReadFile(path)
		if err != nil {
			return nil, errors.Wrapf(err, "failed to read custom index file at `%s`", path)
		}
	}
	indexTemplate, err := template.New("index").Parse(string(indexData))
	if err != nil {
		panic("index template parse failed") // must be valid
	}

	titleTemplate, err := noesctmpl.New("title").Parse(options.TitleFormat)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to parse window title format `%s`", options.TitleFormat)
	}

	var originChekcer func(r *http.Request) bool
	if options.WSOrigin != "" {
		matcher, err := regexp.Compile(options.WSOrigin)
		if err != nil {
			return nil, errors.Wrapf(err, "failed to compile regular expression of Websocket Origin: %s", options.WSOrigin)
		}
		originChekcer = func(r *http.Request) bool {
			return matcher.MatchString(r.Header.Get("Origin"))
		}
	}

	return &Server{
		factory: factory,
		options: options,

		upgrader: &websocket.Upgrader{

View on GitHub (pinned to a080c85cbc)

Solutions

  1. Fix the TitleFormat syntax (balanced {{ }} and valid template actions)
  2. Validate the format string with a dry parse before shipping config
  3. Consult Go text/template syntax; noesctmpl only disables HTML escaping, not the grammar
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/server.go:57 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of yudai/gotty@a080c85cbc (2026-09-02). Data as JSON: /api/errors/210a34a53163243c. Report an issue: GitHub.