glanceapp/glance · error

widget 'type' property is empty or not specified

Error message

widget 'type' property is empty or not specified

What it means

Returned by newWidget() in internal/glance/widget.go when a page defines a widget whose 'type' YAML key is missing or set to an empty string. The type string drives the switch that instantiates the correct widget struct; without it Glance cannot construct anything, so page parsing aborts with this error.

Source

Thrown at internal/glance/widget.go:22

	"bytes"
	"context"
	"errors"
	"fmt"
	"html/template"
	"log/slog"
	"math"
	"net/http"
	"sync/atomic"
	"time"

	"gopkg.in/yaml.v3"
)

var widgetIDCounter atomic.Uint64

func newWidget(widgetType string) (widget, error) {
	if widgetType == "" {
		return nil, errors.New("widget 'type' property is empty or not specified")
	}

	var w widget

	switch widgetType {
	case "calendar":
		w = &calendarWidget{}
	case "calendar-legacy":
		w = &oldCalendarWidget{}
	case "clock":
		w = &clockWidget{}
	case "weather":
		w = &weatherWidget{}
	case "bookmarks":
		w = &bookmarksWidget{}
	case "iframe":
		w = &iframeWidget{}
	case "html":

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Add a valid type: <widget-name> to every item in page contents (e.g. type: bookmarks, type: weather).
  2. Fix indentation so type sits at the same level as the widget's other options.
  3. Remove empty `-` entries from contents lists.
  4. Run `glance config:validate` to get the exact location of the offending widget.

Example fix

# glance.yml (before)
content:
  - name: Home
    widgets:
      -:
        title: Links

# after
content:
  - name: Home
    widgets:
      - type: bookmarks
        title: Links
Defensive patterns

Strategy: validation

Validate before calling

# rough check: every widget item in contents must have a type
python3 - <<'EOF'
import yaml,sys
cfg=yaml.safe_load(open('glance.yml'))
for page in cfg.get('pages',[]):
    for w in page.get('contents',[]):
        assert isinstance(w,dict) and w.get('type'), f'missing type in {page.get("name")}: {w}'
print('ok')
EOF

Prevention

When it happens

Trigger: A YAML mapping under page.contents (or nested under a widget that proxies others, e.g. group) lacks the type key, has `type:` with no value, or has type: "". Also happens when the type key is mis-indented so it lands outside the widget map.

Common situations: Copy-pasting a widget snippet and deleting the type line; YAML indentation drift putting type under the wrong nesting level; commenting out type while testing; an empty trailing `-` item in the contents list.

Related errors


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