{"record":{"id":"3e0f3a9c828276ff","repo":"Jguer/yay","slug":"init-lua-unknown-yay-opt-key-s","errorCode":null,"errorMessage":"init.lua: unknown yay.opt key: %s","messagePattern":"init\\.lua: unknown yay\\.opt key: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/lua/load.go","lineNumber":35,"sourceCode":"\n\tengine := NewWithLogger(luaLogger)\n\tengine.SetSearchDir(filepath.Dir(path))\n\n\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 {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/lua/load.go#L17-L53","documentation":"During Load, the Lua init.lua is executed and any keys set via yay.opt that the engine does not recognize are collected and reported as one error per unknown key, prefixed 'init.lua: unknown yay.opt key: '. This guards against silent no-op configuration caused by typos or removed/renamed options.","triggerScenarios":"Calling settings/lua Load (or LoadInto) with an init.lua that assigns an unrecognized key, e.g. yay.opt.searchby = ... or a misspelled option like yay.opt.sourcerank; keys removed in newer versions also trigger this.","commonSituations":"Typo'd option names in init.lua; following outdated documentation or example configs for renamed options; copying config from another tool that has similarly named options.","solutions":["Fix or remove the offending key in init.lua; the key name is given verbatim in the message.","Check the current yay.opt option list in the settings/lua package for the correct spelling/renames.","If migrating versions, consult the changelog for renamed or removed yay.opt keys.","Register the option in the engine's known-keys set if you are extending the tool with a new option."],"exampleFix":"// init.lua with a typo\n-- before\nyay.opt.searchby = \"fuzzy\"\n-- after\nyay.opt.search_by = \"fuzzy\"  -- actual supported key","handlingStrategy":"validation","validationCode":"// Before loading, scan init.lua for yay.opt assignments and compare with known keys\nknown := map[string]bool{\"search_by\": true /* ... */}\nfor _, key := range extractOptKeys(initLuaSrc) {\n    if !known[key] { log.Printf(\"unknown yay.opt key in init.lua: %s\", key) }\n}","typeGuard":null,"tryCatchPattern":"engine, err := lua.Load(path)\nif err != nil {\n    if strings.Contains(err.Error(), \"unknown yay.opt key\") {\n        log.Printf(\"init.lua has stale/typo'd options: %v\", err)\n    }\n    return err\n}","preventionTips":["Cross-check every yay.opt key against the current supported option list after upgrades","Copy option names from docs/examples rather than typing them from memory","Keep a lint step that greps init.lua for yay.opt. assignments in CI"],"tags":["config","lua","validation","unknown-option"],"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"}