{"record":{"id":"0181f03a9c752204","repo":"Jguer/yay","slug":"unsupported-field-kind-s","errorCode":null,"errorMessage":"unsupported field kind %s","messagePattern":"unsupported field kind (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/lua/lua.go","lineNumber":184,"sourceCode":"\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:\n\t\treturn assignStructSlice(field, val)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported field kind %s\", field.Kind())\n\t}\n\n\treturn nil\n}\n\n// assignStructSlice fills a []Struct field from a Lua table keyed by name, e.g.\n//\n//\t{ [\"core\"] = { url = \"...\" }, [\"extra\"] = { url = \"...\" } }\n//\n// Each entry becomes one struct: the table key populates the element's\n// lua:\"name\" field and the sub-table populates the remaining fields. Entries\n// are sorted by name so the resulting slice is deterministic despite Lua's\n// unordered table iteration.\nfunc assignStructSlice(field reflect.Value, val lua.LValue) error {\n\telemType := field.Type().Elem()\n\tif elemType.Kind() != reflect.Struct {\n\t\treturn fmt.Errorf(\"unsupported slice element kind %s\", elemType.Kind())\n\t}","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/lua/lua.go#L166-L202","documentation":"assign handles only string, bool, int/int64, and slice-of-struct fields; any other Go field kind (float, map, struct value, pointer, etc.) in a lua-tagged struct is unsupported and rejected with the field's reflect.Kind name. This is a schema constraint of the Lua settings engine, not a value problem in init.lua.","triggerScenarios":"Declaring a struct field with a lua tag whose kind is float64, map, nested struct, pointer, uint, etc., then running Load/Apply over it; a refactor changes a field's type away from the supported kinds.","commonSituations":"Adding a float option (Go defaults to float64) or a time.Duration field to the settings struct; embedding a sub-struct where a slice-of-struct was intended; using uint/int32.","solutions":["Change the unsupported field to a supported kind (string, bool, int, or []Struct)","Store the value as an int where possible (e.g. seconds for durations)","Remove the lua tag if the field should not be Lua-configurable"],"exampleFix":"// before\nRatio float64 `lua:\"ratio\"`\n// after\nRatioPercent int `lua:\"ratio_percent\"`","handlingStrategy":"validation","validationCode":"func checkLuaFieldKinds(t reflect.Type) error {\n    for i := 0; i < t.NumField(); i++ {\n        if t.Field(i).Tag.Get(\"lua\") == \"\" { continue }\n        switch t.Field(i).Type.Kind() {\n        case reflect.String, reflect.Bool, reflect.Int, reflect.Int64, reflect.Slice:\n        default:\n            return fmt.Errorf(\"field %s has unsupported kind %s\", t.Field(i).Name, t.Field(i).Type.Kind())\n        }\n        if t.Field(i).Type.Kind() == reflect.Slice && t.Field(i).Type.Elem().Kind() != reflect.Struct {\n            return fmt.Errorf(\"slice field %s must be []Struct\", t.Field(i).Name)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unsupported field kind\") {\n    return fmt.Errorf(\"settings struct incompatible with lua engine: %w\", err)\n}","preventionTips":["Restrict lua-tagged fields to string, bool, int, or []Struct","Add a reflect-based unit test that walks the settings struct and asserts supported kinds","Avoid float64/time.Duration fields in Lua-configurable structs"],"tags":["go","reflection","unsupported-type"],"backgroundTag":"unsupported-operation","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"}