{"record":{"id":"862ff7cd7dd126e9","repo":"Jguer/yay","slug":"expected-string-got-s","errorCode":null,"errorMessage":"expected string, got %s","messagePattern":"expected string, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/lua/lua.go","lineNumber":163,"sourceCode":"func luaFieldIndex(st reflect.Type) map[string]int {\n\tindex := make(map[string]int, st.NumField())\n\n\tfor i := range st.NumField() {\n\t\tfield := st.Field(i)\n\t\tif name := luaKeyForField(&field); name != \"\" {\n\t\t\tindex[name] = i\n\t\t}\n\t}\n\n\treturn index\n}\n\nfunc assign(field reflect.Value, val lua.LValue) error {\n\tswitch field.Kind() {\n\tcase reflect.String:\n\t\ts, ok := val.(lua.LString)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"expected string, got %s\", val.Type())\n\t\t}\n\n\t\tfield.SetString(string(s))\n\tcase reflect.Bool:\n\t\tb, ok := val.(lua.LBool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"expected boolean, got %s\", val.Type())\n\t\t}\n\n\t\tfield.SetBool(bool(b))\n\tcase reflect.Int, reflect.Int64:\n\t\tn, ok := val.(lua.LNumber)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"expected number, got %s\", val.Type())\n\t\t}\n\n\t\tfield.SetInt(int64(n))\n\tcase reflect.Slice:","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/lua/lua.go#L145-L181","documentation":"assign maps a Lua value onto a reflect.String struct field and requires the raw Lua value to be an LString. Any other Lua type (number, boolean, nil, table) cannot be stored in the string field, so it reports the offending Lua type name via val.Type().","triggerScenarios":"An init.lua option bound to a Go string field is set to a non-string, e.g. yay.opt.editor = true or yay.opt.editor = 5 or a table.","commonSituations":"Quoting habits from other languages reversed — forgetting quotes when a string looks like a number elsewhere; assigning nil to 'clear' a string; an editor path accidentally written as a boolean expression result.","solutions":["Wrap the value in quotes in init.lua: yay.opt.editor = \"nvim\"","Convert non-string Lua values with tostring(...) only if the numeric/boolean text is truly intended as a string","Verify the struct field is actually a string kind; if it should be bool/number, fix the Go struct tag instead"],"exampleFix":"// before (init.lua)\nyay.opt.editor = nvim\n// after\nyay.opt.editor = \"nvim\"","handlingStrategy":"validation","validationCode":"-- init.lua\nassert(type(yay.opt.editor) == \"string\", \"yay.opt.editor must be a string\")","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"expected string\") {\n    fixStringOptionInInitLua()\n}","preventionTips":["Quote all string options in init.lua","Never assign nil to string options; use empty string \"\"","Check the Go struct field kind before adding a new yay.opt key"],"tags":["lua","type-mismatch","configuration"],"backgroundTag":"type-mismatch","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"}