{"record":{"id":"702afdf7a428a1f6","repo":"Jguer/yay","slug":"exclude-must-be-a-table","errorCode":null,"errorMessage":"exclude must be a table","messagePattern":"exclude must be a table","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/lua/autocmd.go","lineNumber":367,"sourceCode":"\n\treturn tbl\n}\n\nfunc (e *Engine) parseUpgradeSelectResult(value glua.LValue, validExcludes mapset.Set[string]) (UpgradeSelectResult, error) {\n\tvar result UpgradeSelectResult\n\tif value == glua.LNil {\n\t\treturn result, nil\n\t}\n\n\ttbl, ok := value.(*glua.LTable)\n\tif !ok {\n\t\treturn result, fmt.Errorf(\"callback must return nil or table, got %s\", value.Type())\n\t}\n\n\tif excludeValue := tbl.RawGetString(\"exclude\"); excludeValue != glua.LNil {\n\t\texcludeTbl, ok := excludeValue.(*glua.LTable)\n\t\tif !ok {\n\t\t\treturn result, fmt.Errorf(\"exclude must be a table\")\n\t\t}\n\n\t\tvar parseErr error\n\t\texcludeTbl.ForEach(func(_ glua.LValue, val glua.LValue) {\n\t\t\tif parseErr != nil {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlname, ok := val.(glua.LString)\n\t\t\tif !ok {\n\t\t\t\tparseErr = fmt.Errorf(\"exclude entries must be strings\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tname := string(lname)\n\t\t\tif !validExcludes.Contains(name) {\n\t\t\t\tparseErr = fmt.Errorf(\"unknown upgrade exclusion %q\", name)\n\t\t\t\treturn","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/lua/autocmd.go#L349-L385","documentation":"When the UpgradeSelect callback returns a table, its 'exclude' field must be a table (list of package-name strings); a scalar 'exclude' value produces 'exclude must be a table'. The library throws this to reject malformed hook results rather than guessing the intent.","triggerScenarios":"Callback returns { exclude = <non-table> } — e.g. exclude = 'linux', exclude = 42, or exclude = true.","commonSituations":"Passing a single package name as a string instead of a list; Lua config built by string concatenation producing the wrong type; misunderstanding that exclude is a set-like table of names.","solutions":["Wrap the value in a table: exclude = { 'pkg1', 'pkg2' }","Use an empty table exclude = {} if nothing should be excluded","Omit the exclude key entirely when not needed","Verify the variable holding the exclude list is actually a table (type(x) == 'table')"],"exampleFix":"-- before\nreturn { exclude = 'linux-kernel' }\n-- after\nreturn { exclude = { 'linux-kernel' } }","handlingStrategy":"validation","validationCode":"local r = myUpgradeSelect(mockEvent)\nassert(r == nil or r.exclude == nil or type(r.exclude) == 'table', 'exclude must be a table')","typeGuard":"local function hasListExclude(r) return r == nil or r.exclude == nil or type(r.exclude) == 'table' end","tryCatchPattern":null,"preventionTips":["Always pass exclude as a list table, even for one entry","Use {} for no exclusions instead of omitting via nil in a loop","Document the expected result shape in your config comments"],"tags":["lua","validation","type-mismatch","upgrade"],"backgroundTag":"type-mismatch","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}