glanceapp/glance · error

search bang #%d has no URL

Error message

search bang #%d has no URL

What it means

Returned by searchWidget's config validation (internal/glance/widget-search.go:66) when a bangs[] entry has a shortcut but no url key. Same lifecycle as 137: fires at startup, fails the whole search widget, position reported in the message. Note the URL must also survive convertSearchUrl — a URL without a {QUERY} placeholder may be left unusable, though only an empty string triggers this specific error.

Source

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

	}

	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 url key with the search URL containing the {QUERY} placeholder
  2. Use exact key names: shortcut and url
  3. Verify with the error's #N which bang item is missing its url

Example fix

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

Strategy: validation

Validate before calling

for i, b := range bangs {
    if b.URL == "" {
        return fmt.Errorf("bang %d missing url", i)
    }
}

Try / catch

// Config error surfaced at widget init; correct the url key in glance.yml

Prevention

When it happens

Trigger: A bang with shortcut: g but a misspelled 'link:'/'href:' key instead of url:, or url left empty (url:) — validation rejects the empty string before convertSearchUrl runs.

Common situations: Renaming url to a preferred key name; template copy-paste where the URL line was commented out; refactoring config and dropping the url line while keeping shortcut.

Related errors


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