Jguer/yay · error

exclude entries must be strings

Error message

exclude entries must be strings

What it means

Each entry of the returned 'exclude' table must be a Lua string; a non-string value (number, boolean, nested table, nil) sets parseErr to 'exclude entries must be strings', which RunUpgradeSelect wraps as 'UpgradeSelect: <that error>'. Thrown to guarantee the exclude list can be compared against package names.

Solutions

  1. Ensure every element is a quoted string: { 'linux', 'zfs-dkms' }
  2. Convert numbers with tostring() if a name is numeric
  3. Extract the name field if you have package tables: exclude = { pkg.name }
  4. Remove nil holes that shift array contents

Example fix

-- before
return { exclude = { 123 } }
-- after
return { exclude = { tostring(123) } }
Defensive patterns

Strategy: validation

Validate before calling

for i, v in ipairs(result.exclude or {}) do
  if type(v) ~= 'string' then error('exclude[' .. i .. '] must be a string') end
end

Type guard

local function allStrings(t)
  if t == nil then return true end
  for _, v in ipairs(t) do if type(v) ~= 'string' then return false end end
  return true
end

Prevention

When it happens

Trigger: Callback returns { exclude = { 1, true, {'linux'} } } — any ForEach iteration encountering a non-LString value.

Common situations: Using numeric indices values by accident ({ [1]=123 }); passing package objects/tables instead of their name fields; JSON-ish data pasted into Lua with numbers as names.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07). Data as JSON: /api/errors/b00d00bc7631f804. Report an issue: GitHub.

Appendix: source

Thrown at pkg/settings/lua/autocmd.go:378

	if !ok {
		return result, fmt.Errorf("callback must return nil or table, got %s", value.Type())
	}

	if excludeValue := tbl.RawGetString("exclude"); excludeValue != glua.LNil {
		excludeTbl, ok := excludeValue.(*glua.LTable)
		if !ok {
			return result, fmt.Errorf("exclude must be a table")
		}

		var parseErr error
		excludeTbl.ForEach(func(_ glua.LValue, val glua.LValue) {
			if parseErr != nil {
				return
			}

			lname, ok := val.(glua.LString)
			if !ok {
				parseErr = fmt.Errorf("exclude entries must be strings")
				return
			}

			name := string(lname)
			if !validExcludes.Contains(name) {
				parseErr = fmt.Errorf("unknown upgrade exclusion %q", name)
				return
			}

			result.Exclude = append(result.Exclude, name)
		})
		if parseErr != nil {
			return result, parseErr
		}
	}

	if skipMenuValue := tbl.RawGetString("skip_menu"); skipMenuValue != glua.LNil {
		skipMenu, ok := skipMenuValue.(glua.LBool)

View on GitHub (pinned to 328f4b4939)