{"record":{"id":"100f1650f0df1908","repo":"Jguer/yay","slug":"yay-opt-s-w","errorCode":null,"errorMessage":"yay.opt.%s: %w","messagePattern":"yay\\.opt\\.(.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/lua/lua.go","lineNumber":86,"sourceCode":"\tif !ok {\n\t\treturn nil, nil\n\t}\n\n\toptTbl.ForEach(func(k, val lua.LValue) {\n\t\tkey, ok := k.(lua.LString)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\tfieldIdx, found := index[string(key)]\n\t\tif !found {\n\t\t\tunknown = append(unknown, string(key))\n\n\t\t\treturn\n\t\t}\n\n\t\tif err := assign(sv.Field(fieldIdx), val); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"yay.opt.%s: %w\", string(key), err))\n\t\t}\n\t})\n\n\treturn unknown, errs\n}\n\nfunc (e *Engine) optTable() (*lua.LTable, bool) {\n\tyayTbl, ok := e.L.GetGlobal(globalName).(*lua.LTable)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\toptTbl, ok := e.L.GetField(yayTbl, optTableName).(*lua.LTable)\n\n\treturn optTbl, ok\n}\n\n// SetSearchDir makes require() resolve modules relative to dir (e.g.","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/lua/lua.go#L68-L104","documentation":"When Apply iterates the Lua yay.opt table, a recognized key whose value cannot be assigned to the corresponding struct field (wrong Lua type for the field) is recorded as 'yay.opt.<key>: <cause>'. The error is collected rather than thrown immediately so Apply can report every bad option at once; Load then wraps these into the joined init.lua error.","triggerScenarios":"A yay.opt entry in init.lua targets a known field but carries a value whose Lua type does not match the field kind handled by assign — e.g. a string assigned to a bool/int field, or a non-table assigned to a slice field.","commonSituations":"Quoting numbers (yay.opt.retries = \"3\" when the field is int); assigning a string where a boolean is expected; assigning a scalar to a struct-slice field.","solutions":["Read the wrapped cause after 'yay.opt.<key>:' — it names the expected vs actual type","Correct the Lua value's type in init.lua (remove quotes for numbers/booleans, use a table for slices)","Check the struct field's Go type (and lua tag) to confirm the expected Lua type"],"exampleFix":"// before (init.lua)\nyay.opt.rebuild = \"true\"   -- string, field is bool\n// after\nyay.opt.rebuild = true","handlingStrategy":"validation","validationCode":"// Validate each yay.opt value type against the struct field before loading\n// e.g. for a bool field, require Lua true/false; for int, a bare number.\n-- init.lua self-check\nassert(type(yay.opt.rebuild) == \"boolean\", \"rebuild must be boolean\")\nassert(type(yay.opt.retries) == \"number\", \"retries must be number\")","typeGuard":null,"tryCatchPattern":"_, errs := engine.Apply(&cfg)\nfor _, e := range errs {\n    var target error\n    if errors.As(e, &target) { log.Printf(\"bad option: %v\", e) }\n}","preventionTips":["Match Lua literal types to Go field kinds: no quotes for numbers/bools","Keep a sample init.lua in docs showing the correct type per key","Add Lua assert(type(...)) checks at the top of init.lua"],"tags":["lua","configuration","type-mismatch"],"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"}