glanceapp/glance · error

subreddit is required

Error message

subreddit is required

What it means

Thrown by the reddit widget's initialize() when subreddit is empty. The subreddit name drives both the widget title ('r/<name>') and the request URL used to fetch posts, so it is the one required field; sort-by and top-period get defaults instead of erroring.

Source

Thrown at internal/glance/widget-reddit.go:58

	CommentsURLTemplate string            `yaml:"comments-url-template"`
	Limit               int               `yaml:"limit"`
	CollapseAfter       int               `yaml:"collapse-after"`
	RequestURLTemplate  string            `yaml:"request-url-template"`

	AppAuth struct {
		Name   string `yaml:"name"`
		ID     string `yaml:"id"`
		Secret string `yaml:"secret"`

		enabled        bool
		accessToken    string
		tokenExpiresAt time.Time
	} `yaml:"app-auth"`
}

func (widget *redditWidget) initialize() error {
	if widget.Subreddit == "" {
		return errors.New("subreddit is required")
	}

	if widget.Limit <= 0 {
		widget.Limit = 15
	}

	if widget.CollapseAfter == 0 || widget.CollapseAfter < -1 {
		widget.CollapseAfter = 5
	}

	s := widget.SortBy
	if s != "hot" && s != "new" && s != "top" && s != "rising" {
		widget.SortBy = "hot"
	}

	p := widget.TopPeriod
	if p != "hour" && p != "day" && p != "week" && p != "month" && p != "year" && p != "all" {
		widget.TopPeriod = "day"

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Set subreddit: to a single community name without the r/ prefix, e.g. subreddit: selfhosted
  2. For multiple communities, add one reddit widget per subreddit
  3. Verify the key is spelled 'subreddit' and top-level within the widget

Example fix

# before
- type: reddit
  sort-by: top

# after
- type: reddit
  subreddit: selfhosted
  sort-by: top
Defensive patterns

Strategy: validation

Validate before calling

if w['type'] == 'reddit' and not w.get('subreddit'):
    raise ValueError('reddit widget requires subreddit')

Prevention

When it happens

Trigger: A widget of type: reddit with no subreddit key; subreddit misspelled (sub-reddit:, sub:); an empty value from a templated/generated config.

Common situations: Copy-pasting the reddit widget example and forgetting to fill in the subreddit; multi-subreddit users expecting a list (only a single name is supported here).

Related errors


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