wtfutil/wtf · warning

unable to get the league id for provided league '%s'

Error message

unable to get the league id for provided league '%s'

What it means

NewWidget resolves the configured league name via getLeague(settings.league); on failure it stores "unable to get the league id for provided league '%s'" in the widget's err field instead of panicking. This is a configuration-time error: the league string in the widget settings does not map to any known league ID.

Source

Thrown at modules/football/widget.go:46

	"WC":  {2000, "FIFA World Cup"},
}

type Widget struct {
	view.TextWidget
	*Client
	settings *Settings
	League   leagueInfo
	err      error
}

func NewWidget(tviewApp *tview.Application, redrawChan chan bool, pages *tview.Pages, settings *Settings) *Widget {
	var widget Widget

	leagueId, err := getLeague(settings.league)
	if err != nil {
		widget = Widget{
			TextWidget: view.NewTextWidget(tviewApp, redrawChan, pages, settings.Common),
			err:        fmt.Errorf("unable to get the league id for provided league '%s'", settings.league),
			Client:     NewClient(settings.apiKey),
			settings:   settings,
		}

		return &widget
	}

	widget = Widget{
		TextWidget: view.NewTextWidget(tviewApp, redrawChan, pages, settings.Common),
		Client:     NewClient(settings.apiKey),
		League:     leagueId,
		settings:   settings,
	}

	return &widget
}

func (widget *Widget) Refresh() {

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Check the league string against the leagueID map keys in modules/football (the supported codes).
  2. Fix casing/spelling in the config: league must exactly match a map key.
  3. Use a code documented by football-data.org (e.g., PL, BL1, SA, PD) if the map mirrors those.
  4. If the league genuinely is unsupported, add it to the leagueID map.

Example fix

// config before
football:
  league: premier league
// config after
football:
  league: PL
Defensive patterns

Strategy: validation

Validate before calling

supported := map[string]bool{"PL": true, "BL1": true, "SA": true, "PD": true} // mirror leagueID keys
if !supported[strings.TrimSpace(settings.league)] {
	return fmt.Errorf("league %q not supported; use one of PL, BL1, SA, PD", settings.league)
}

Type guard

func isValidLeague(league string, leagueID map[string]leagueInfo) bool {
	_, ok := leagueID[strings.TrimSpace(league)]
	return ok
}

Try / catch

widget := football.NewWidget(tviewApp, redrawChan, pages, settings)
if widget.Err() != nil {
	log.Printf("football widget disabled: %v", widget.Err()) // degrade, keep app running
	return
}

Prevention

When it happens

Trigger: settings.league (from the wtf config file) is not a key in the leagueID map — e.g., "PL" vs "pl" casing mismatch, "bundesliga" vs "bl1", or an unsupported competition.

Common situations: Typos in .wtf/config.yml, wrong casing, using a competition code from a different API provider, or adding a league the map does not yet support.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/9738b5ba34adad25. Report an issue: GitHub.