{"record":{"id":"4546f06077a8669e","repo":"muesli/duf","slug":"unknown-column-s-valid-s","errorCode":null,"errorMessage":"unknown column: %s (valid: %s)","messagePattern":"unknown column: (.+?) \\(valid: (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"table.go","lineNumber":550,"sourceCode":"\t\t\treturn\n\t\t}\n\t} else {\n\t\tsize = num\n\t}\n\treturn\n}\n\n// stringToColumn converts a column name to its index.\nfunc stringToColumn(s string) (int, error) {\n\ts = strings.ToLower(s)\n\n\tfor i, v := range columns {\n\t\tif v.ID == s {\n\t\t\treturn i + 1, nil\n\t\t}\n\t}\n\n\treturn 0, fmt.Errorf(\"unknown column: %s (valid: %s)\", s, strings.Join(columnIDs(), \", \"))\n}\n\n// stringToSortIndex converts a column name to its sort index.\nfunc stringToSortIndex(s string) (int, error) {\n\ts = strings.ToLower(s)\n\n\tfor _, v := range columns {\n\t\tif v.ID == s {\n\t\t\treturn v.SortIndex, nil\n\t\t}\n\t}\n\n\treturn 0, fmt.Errorf(\"unknown column: %s (valid: %s)\", s, strings.Join(columnIDs(), \", \"))\n}\n\n// columnsIDs returns a slice of all column IDs.\nfunc columnIDs() []string {\n\ts := make([]string, len(columns))","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/muesli/duf/blob/4636deb4a7b707a9f04c602db033f9837e50b3f6/table.go#L532-L568","documentation":"stringToColumn converts a column name string to its index in the columns table by comparing against each column's ID. If no column matches, it returns \"unknown column: %s (valid: %s)\" including the full list of valid IDs. Used when parsing user-specified output columns.","triggerScenarios":"parseColumns receives a --columns value (case-sensitive, lowercased by the caller) that is not a known column ID, e.g. --columns device,filesystem when only \"device\", \"used\", etc. exist.","commonSituations":"Typos in column names, assuming full names like \"filesystem\" where the ID is abbreviated (e.g. \"fs\"), or using column names from different disk-usage tools (df -h style headers).","solutions":["Use one of the valid IDs listed in the error message's (valid: ...) suffix.","Check spelling and case against the error's valid list.","Update scripts to column IDs if the tool version changed the set of columns."],"exampleFix":"// before\n--columns device,filesystem\n// after\n--columns device,fs","handlingStrategy":"validation","validationCode":"valid := strings.Join(columnIDs(), \",\")\nfor _, c := range strings.Split(columnsFlag, \",\") {\n\tif !strings.Contains(\",\"+valid+\",\", \",\"+c+\",\") { /* unknown column */ }\n}","typeGuard":null,"tryCatchPattern":"idx, err := stringToColumn(name)\nif err != nil {\n\treturn fmt.Errorf(\"%w; use one of: %s\", err, strings.Join(columnIDs(), \", \"))\n}","preventionTips":["Use only column IDs from the (valid: ...) list in the error.","Watch for abbreviations (fs, not filesystem).","Regenerate hardcoded column lists when upgrading the tool."],"tags":["go","cli","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"4636deb4a7b707a9f04c602db033f9837e50b3f6","analyzedAt":"2026-09-06T02:31:58.576Z","contentChangedAt":"2026-09-06T02:31:58.576Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}