wtfutil/wtf · warning

no such league

Error message

no such league

What it means

getLeague looks up the league string in the package-level leagueID map and returns the sentinel error "no such league" when the key is absent. It is the underlying cause of error [67]; NewWidget wraps it contextually. The lookup is exact-match, case-sensitive.

Source

Thrown at modules/football/widget.go:88

	var content string
	title := fmt.Sprintf("%s %s", widget.CommonSettings().Title, widget.League.caption)
	wrap := false
	if widget.err != nil {
		return title, widget.err.Error(), true
	}
	content += widget.GetStandings(widget.League.id)
	content += widget.GetMatches(widget.League.id)

	return title, content, wrap
}

func getLeague(league string) (leagueInfo, error) {

	var l leagueInfo
	if val, ok := leagueID[league]; ok {
		return val, nil
	}
	return l, fmt.Errorf("no such league")
}

// GetStandings of particular league
func (widget *Widget) GetStandings(leagueId int) string {

	var l LeagueStandings
	var content string
	content += "Standings:\n\n"
	buf := new(bytes.Buffer)
	tStandings := createTable([]string{"No.", "Team", "MP", "Won", "Draw", "Lost", "GD", "Points"}, buf)
	resp, err := widget.footballRequest("standings", leagueId)
	if err != nil {
		return fmt.Sprintf("Error fetching standings: %s", err.Error())
	}
	defer func() { _ = resp.Body.Close() }()
	data, err := io.ReadAll(resp.Body)
	if err != nil {
		return fmt.Sprintf("Error fetching standings: %s", err.Error())

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Print/list the leagueID map keys and pick an exact match.
  2. Normalize input before lookup: strings.TrimSpace and canonical casing.
  3. Return the map's available keys in the error message to make misconfiguration self-diagnosing.
  4. Add the missing league to leagueID if it should be supported.

Example fix

// before
return l, fmt.Errorf("no such league")
// after
keys := make([]string, 0, len(leagueID))
for k := range leagueID {
	keys = append(keys, k)
}
return l, fmt.Errorf("no such league %q; supported: %v", league, keys)
Defensive patterns

Strategy: validation

Validate before calling

league = strings.ToUpper(strings.TrimSpace(league))
if _, ok := leagueID[league]; !ok {
	return fmt.Errorf("unknown league %q", league)
}

Type guard

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

Try / catch

id, err := getLeague(settings.league)
if err != nil {
	log.Printf("config error: %v (valid: PL, BL1, SA, PD ...)", err)
	return // skip widget instead of rendering an error state
}

Prevention

When it happens

Trigger: getLeague called with any string not present as a key in leagueID — unknown code, wrong case, whitespace, or unsupported competition.

Common situations: Config value "epl" when the map expects "PL", trailing spaces from YAML, renaming of competition codes by the upstream API, or tests exercising the unknown-league path.

Related errors


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