{"record":{"id":"f0254ba34f6f8292","repo":"Jguer/yay","slug":"init-lua-w","errorCode":null,"errorMessage":"init.lua: %w","messagePattern":"init\\.lua: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/lua/load.go","lineNumber":39,"sourceCode":"\tif err := engine.L.DoFile(path); err != nil {\n\t\tengine.Close()\n\t\treturn nil, err\n\t}\n\n\tunknown, errs := engine.Apply(cfg)\n\n\tif len(unknown) == 0 && len(errs) == 0 {\n\t\treturn engine, nil\n\t}\n\n\tvar joinErrs []error\n\n\tfor _, key := range unknown {\n\t\tjoinErrs = append(joinErrs, fmt.Errorf(\"init.lua: unknown yay.opt key: %s\", key))\n\t}\n\n\tfor _, err := range errs {\n\t\tjoinErrs = append(joinErrs, fmt.Errorf(\"init.lua: %w\", err))\n\t}\n\n\tif err := errors.Join(joinErrs...); err != nil {\n\t\tengine.Close()\n\t\treturn nil, err\n\t}\n\n\treturn engine, nil\n}\n\n// LoadInto applies the yay.opt values from path onto cfg.\nfunc LoadInto(logger *text.Logger, path string, cfg any) error {\n\tengine, err := Load(logger, path, cfg)\n\tif engine != nil {\n\t\tdefer engine.Close()\n\t}\n\n\treturn err","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/lua/load.go#L21-L57","documentation":"Load runs the bundled init.lua and collects every error found while executing it and applying its yay.opt table, wrapping each one with an 'init.lua: ' prefix and joining them with errors.Join. It exists so a user with a broken Lua settings file sees ALL problems at once, not just the first. If any errors were collected, the engine is closed and the joined error is returned, so Load never partially succeeds.","triggerScenarios":"Calling Load on a directory whose init.lua either fails to execute (syntax error, runtime error in Lua) or contains one or more unknown yay.opt keys or values that fail type validation in Apply.","commonSituations":"See trigger scenarios.","solutions":["Read each 'init.lua: '-prefixed line in the returned (joined) error; each line is one independent problem","Fix every unknown yay.opt key listed — remove it or rename it to a key the current version supports","Fix the underlying Lua error(s) reported after the prefix (syntax/runtime error, type mismatch)","Re-run Load until it returns no error; the multi-error report updates with remaining issues"],"exampleFix":"// before (init.lua)\nyay.opt.daemon_interval = 10  -- unknown/renamed key\n// after\nyay.opt.devel_interval = 10","handlingStrategy":"validation","validationCode":"// Pre-validate init.lua with a dry engine before committing settings\nengine, err := lua.Load(dir)\nif err != nil {\n    for _, line := range strings.Split(err.Error(), \"\\n\") {\n        log.Printf(\"init.lua problem: %s\", line)\n    }\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := runLoad(); err != nil {\n    var joined interface{ Unwrap() []error }\n    if errors.As(err, &joined) { for _, e := range joined.Unwrap() { handle(e) } }\n}","preventionTips":["Run Load in CI against the real init.lua so bad keys fail the build","Keep a test that Applies a canary init.lua listing every supported yay.opt key","After upgrading yay, grep init.lua for renamed keys and diff against the current schema"],"tags":["lua","configuration","error-joining"],"backgroundTag":"invalid-config-value","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"}