Jguer/yay · error

entry must be a table, got

Error message

entry %q must be a table, got %s

What it means

Thrown by the Lua settings loader when iterating an array-of-structs option table: each entry's value must itself be a Lua table, but it was another type (string, number, boolean, function, nil). The loader maps named entry tables onto Go struct fields via reflection, so a non-table entry cannot be assigned.

Solutions

  1. Open the Lua config at the reported entry key and wrap the value in a table: `entry = { field = value }`.
  2. Check the Go struct for that option (lua:"..." tags) to see which fields the entry table must contain.
  3. If the value should be a list of plain strings, use a different option type rather than forcing it into the struct-slice option.

Example fix

-- before
aliases = { ls = "ls --color" }
-- after
aliases = { ls = { cmd = "ls --color" } }
Defensive patterns

Strategy: validation

Validate before calling

-- validate before loading
for name, entry in pairs(opt) do
  assert(type(entry) == "table", "entry " .. name .. " must be a table, got " .. type(entry))
end

Prevention

When it happens

Trigger: A Lua config like `opt = { myname = "value" }` or `opt = { myname = 42 }` where the schema expects `opt = { myname = { field = ... } }`; the entry under key `name` is checked with `entry.(*lua.LTable)` and fails.

Common situations: Users migrating configs from flat key=value formats, copy-pasting snippets for a different option that accepts scalars, or forgetting the inner table braces around struct fields.

Related errors


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

Appendix: source

Thrown at pkg/settings/lua/lua.go:239

	var (
		entries  []namedElem
		firstErr error
	)

	tbl.ForEach(func(k, entry lua.LValue) {
		if firstErr != nil {
			return
		}

		name, ok := k.(lua.LString)
		if !ok {
			firstErr = fmt.Errorf("entry keys must be strings, got %s", k.Type())
			return
		}

		entryTbl, ok := entry.(*lua.LTable)
		if !ok {
			firstErr = fmt.Errorf("entry %q must be a table, got %s", string(name), entry.Type())
			return
		}

		elem := reflect.New(elemType).Elem()
		if hasName {
			elem.Field(nameIdx).SetString(string(name))
		}

		if err := assignStructFields(elem, entryTbl, fieldIndex); err != nil {
			firstErr = fmt.Errorf("entry %q: %w", string(name), err)
			return
		}

		entries = append(entries, namedElem{name: string(name), elem: elem})
	})

	if firstErr != nil {
		return firstErr

View on GitHub (pinned to 328f4b4939)