glanceapp/glance · error

search bang #%d has no shortcut

Error message

search bang #%d has no shortcut

What it means

Returned by searchWidget's config validation (internal/glance/widget-search.go:62) when a bangs[] entry in glance.yml lacks a shortcut key. Bangs are the '!g query'-style shortcuts; each needs both shortcut and URL. Validation runs at widget init, so a single bad entry prevents the whole search widget from rendering. The message includes the 1-based position of the offending bang.

Source

Thrown at internal/glance/widget-search.go:62

	widget.withTitle("Search").withError(nil)

	if widget.SearchEngine == "" {
		widget.SearchEngine = "duckduckgo"
	}

	if widget.Placeholder == "" {
		widget.Placeholder = "Type here to search…"
	}

	if url, ok := searchEngines[widget.SearchEngine]; ok {
		widget.SearchEngine = url
	}

	widget.SearchEngine = convertSearchUrl(widget.SearchEngine)

	for i := range widget.Bangs {
		if widget.Bangs[i].Shortcut == "" {
			return fmt.Errorf("search bang #%d has no shortcut", i+1)
		}

		if widget.Bangs[i].URL == "" {
			return fmt.Errorf("search bang #%d has no URL", i+1)
		}

		widget.Bangs[i].URL = convertSearchUrl(widget.Bangs[i].URL)
	}

	widget.cachedHTML = widget.renderTemplate(widget, searchWidgetTemplate)
	return nil
}

func (widget *searchWidget) Render() template.HTML {
	return widget.cachedHTML
}

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Add the shortcut key to the offending bang (the message's #N tells you which item): shortcut: g
  2. Check YAML indentation — shortcut and url must be keys of the same bang map
  3. Remove incomplete bang entries entirely

Example fix

// before (glance.yml)
widget:
  type: search
  bangs:
    - url: https://github.com/search?q=QUERY
// after
widget:
  type: search
  bangs:
    - shortcut: gh
      url: https://github.com/search?q=QUERY
Defensive patterns

Strategy: validation

Validate before calling

// Validate bangs config before startup
for i, b := range bangs {
    if b.Shortcut == "" {
        return fmt.Errorf("bang %d missing shortcut", i)
    }
}

Try / catch

// Go: config validation fails at init; render-time handling is unnecessary — fix glance.yml

Prevention

When it happens

Trigger: A bangs list item defining only url: (or with the shortcut key misspelled as 'key:'/'trigger:'), or an item that is an empty map. Example: bangs: [{ url: https://duckduckgo.com/?q=QUERY }].

Common situations: Copy-pasting bang config from docs and deleting/renaming the shortcut line; assuming the URL domain becomes the shortcut implicitly; indentation making shortcut a sibling of the bang item instead of inside it.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/d65bbdfcf82e4fde. Report an issue: GitHub.