{"record":{"id":"a4e0754d812364ef","repo":"wtfutil/wtf","slug":"no-such-league","errorCode":null,"errorMessage":"no such league","messagePattern":"no such league","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/football/widget.go","lineNumber":88,"sourceCode":"\tvar content string\n\ttitle := fmt.Sprintf(\"%s %s\", widget.CommonSettings().Title, widget.League.caption)\n\twrap := false\n\tif widget.err != nil {\n\t\treturn title, widget.err.Error(), true\n\t}\n\tcontent += widget.GetStandings(widget.League.id)\n\tcontent += widget.GetMatches(widget.League.id)\n\n\treturn title, content, wrap\n}\n\nfunc getLeague(league string) (leagueInfo, error) {\n\n\tvar l leagueInfo\n\tif val, ok := leagueID[league]; ok {\n\t\treturn val, nil\n\t}\n\treturn l, fmt.Errorf(\"no such league\")\n}\n\n// GetStandings of particular league\nfunc (widget *Widget) GetStandings(leagueId int) string {\n\n\tvar l LeagueStandings\n\tvar content string\n\tcontent += \"Standings:\\n\\n\"\n\tbuf := new(bytes.Buffer)\n\ttStandings := createTable([]string{\"No.\", \"Team\", \"MP\", \"Won\", \"Draw\", \"Lost\", \"GD\", \"Points\"}, buf)\n\tresp, err := widget.footballRequest(\"standings\", leagueId)\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Error fetching standings: %s\", err.Error())\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\tdata, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Error fetching standings: %s\", err.Error())","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/football/widget.go#L70-L106","documentation":"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.","triggerScenarios":"getLeague called with any string not present as a key in leagueID — unknown code, wrong case, whitespace, or unsupported competition.","commonSituations":"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.","solutions":["Print/list the leagueID map keys and pick an exact match.","Normalize input before lookup: strings.TrimSpace and canonical casing.","Return the map's available keys in the error message to make misconfiguration self-diagnosing.","Add the missing league to leagueID if it should be supported."],"exampleFix":"// before\nreturn l, fmt.Errorf(\"no such league\")\n// after\nkeys := make([]string, 0, len(leagueID))\nfor k := range leagueID {\n\tkeys = append(keys, k)\n}\nreturn l, fmt.Errorf(\"no such league %q; supported: %v\", league, keys)","handlingStrategy":"validation","validationCode":"league = strings.ToUpper(strings.TrimSpace(league))\nif _, ok := leagueID[league]; !ok {\n\treturn fmt.Errorf(\"unknown league %q\", league)\n}","typeGuard":"func leagueExists(league string) bool {\n\t_, ok := leagueID[strings.TrimSpace(league)]\n\treturn ok\n}","tryCatchPattern":"id, err := getLeague(settings.league)\nif err != nil {\n\tlog.Printf(\"config error: %v (valid: PL, BL1, SA, PD ...)\", err)\n\treturn // skip widget instead of rendering an error state\n}","preventionTips":["Normalize league input (TrimSpace + case folding) before map lookup.","Keep the config value and map keys in a single source of truth or doc.","Add a unit test enumerating all supported league codes."],"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"}