Jguer/yay · error
%s: %w
Error message
%s: %w
What it means
A wrapper error: once a key in a struct entry table resolves to a struct field, the value is converted by `assign`; any conversion failure is re-wrapped as `<key>: <cause>` to attribute the failure to the specific field.
Solutions
- Look at the cause after the `key:` prefix; fix the value's type for that key.
- Booleans must be `true`/`false` in Lua, not strings; numbers must be valid for the field's Go type.
- Consult the option's Go field type in the settings struct to determine the accepted Lua type.
Example fix
-- before debug = "true" -- after debug = true
Defensive patterns
Strategy: validation
Validate before calling
-- coerce/verify value types before load assert(type(debug) == "boolean", "debug must be boolean") assert(type(level) == "number", "level must be number")
Try / catch
if err := load(cfg); err != nil {
// message is `<key>: <cause>`; surface the key to the user
return fmt.Errorf("bad config value: %w", err)
} Prevention
- Use Lua booleans/numbers natively — never quote `"true"`
- Match each option's value type to its documented Go field type
- Validate the whole config with a small Lua pre-flight script
When it happens
Trigger: Value type mismatch for a known key, e.g. `debug = "yes"` where the Go field is bool, or a nested table where a scalar is expected; `assign` returns an error which is wrapped.
Common situations: Wrong value type for a known option (string vs boolean vs number), out-of-range numbers, or supplying a table to a scalar option.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/736383b65df90bbe.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/settings/lua/lua.go:300
tbl.ForEach(func(k, entry lua.LValue) {
if firstErr != nil {
return
}
key, ok := k.(lua.LString)
if !ok {
firstErr = fmt.Errorf("keys must be strings, got %s", k.Type())
return
}
fieldIdx, found := index[string(key)]
if !found {
firstErr = fmt.Errorf("unknown key %q", string(key))
return
}
if err := assign(sv.Field(fieldIdx), entry); err != nil {
firstErr = fmt.Errorf("%s: %w", string(key), err)
}
})
return firstErr
}
View on GitHub (pinned to 328f4b4939)