{"record":{"id":"9738b5ba34adad25","repo":"wtfutil/wtf","slug":"unable-to-get-the-league-id-for-provided-league","errorCode":null,"errorMessage":"unable to get the league id for provided league '%s'","messagePattern":"unable to get the league id for provided league '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/football/widget.go","lineNumber":46,"sourceCode":"\t\"WC\":  {2000, \"FIFA World Cup\"},\n}\n\ntype Widget struct {\n\tview.TextWidget\n\t*Client\n\tsettings *Settings\n\tLeague   leagueInfo\n\terr      error\n}\n\nfunc NewWidget(tviewApp *tview.Application, redrawChan chan bool, pages *tview.Pages, settings *Settings) *Widget {\n\tvar widget Widget\n\n\tleagueId, err := getLeague(settings.league)\n\tif err != nil {\n\t\twidget = Widget{\n\t\t\tTextWidget: view.NewTextWidget(tviewApp, redrawChan, pages, settings.Common),\n\t\t\terr:        fmt.Errorf(\"unable to get the league id for provided league '%s'\", settings.league),\n\t\t\tClient:     NewClient(settings.apiKey),\n\t\t\tsettings:   settings,\n\t\t}\n\n\t\treturn &widget\n\t}\n\n\twidget = Widget{\n\t\tTextWidget: view.NewTextWidget(tviewApp, redrawChan, pages, settings.Common),\n\t\tClient:     NewClient(settings.apiKey),\n\t\tLeague:     leagueId,\n\t\tsettings:   settings,\n\t}\n\n\treturn &widget\n}\n\nfunc (widget *Widget) Refresh() {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/football/widget.go#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the league string against the leagueID map keys in modules/football (the supported codes).","Fix casing/spelling in the config: league must exactly match a map key.","Use a code documented by football-data.org (e.g., PL, BL1, SA, PD) if the map mirrors those.","If the league genuinely is unsupported, add it to the leagueID map."],"exampleFix":"// config before\nfootball:\n  league: premier league\n// config after\nfootball:\n  league: PL","handlingStrategy":"validation","validationCode":"supported := map[string]bool{\"PL\": true, \"BL1\": true, \"SA\": true, \"PD\": true} // mirror leagueID keys\nif !supported[strings.TrimSpace(settings.league)] {\n\treturn fmt.Errorf(\"league %q not supported; use one of PL, BL1, SA, PD\", settings.league)\n}","typeGuard":"func isValidLeague(league string, leagueID map[string]leagueInfo) bool {\n\t_, ok := leagueID[strings.TrimSpace(league)]\n\treturn ok\n}","tryCatchPattern":"widget := football.NewWidget(tviewApp, redrawChan, pages, settings)\nif widget.Err() != nil {\n\tlog.Printf(\"football widget disabled: %v\", widget.Err()) // degrade, keep app running\n\treturn\n}","preventionTips":["Copy league codes exactly from the leagueID map / football-data.org docs.","Trim whitespace and normalize casing when loading YAML settings.","Test widget config with NewWidget in a dry run before deploying config changes."],"tags":["configuration","validation","go"],"backgroundTag":"invalid-league-name","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}