{"record":{"id":"b289075a5bfb08ca","repo":"Jguer/yay","slug":"result-source-must-be-a-string","errorCode":null,"errorMessage":"result source must be a string","messagePattern":"result source must be a string","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/lua/autocmd.go","lineNumber":642,"sourceCode":"\t\tparseErr error\n\t)\n\n\tseen := mapset.NewThreadUnsafeSet[SearchResultRef]()\n\n\ttbl.ForEach(func(_ glua.LValue, val glua.LValue) {\n\t\tif parseErr != nil {\n\t\t\treturn\n\t\t}\n\n\t\tentry, ok := val.(*glua.LTable)\n\t\tif !ok {\n\t\t\tparseErr = fmt.Errorf(\"each result must be a table\")\n\t\t\treturn\n\t\t}\n\n\t\tsource, ok := entry.RawGetString(\"source\").(glua.LString)\n\t\tif !ok {\n\t\t\tparseErr = fmt.Errorf(\"result source must be a string\")\n\t\t\treturn\n\t\t}\n\n\t\tname, ok := entry.RawGetString(\"name\").(glua.LString)\n\t\tif !ok {\n\t\t\tparseErr = fmt.Errorf(\"result name must be a string\")\n\t\t\treturn\n\t\t}\n\n\t\tref := SearchResultRef{Source: string(source), Name: string(name)}\n\t\tif _, exists := valid[ref]; !exists {\n\t\t\tparseErr = fmt.Errorf(\"unknown search result %s/%s\", ref.Source, ref.Name)\n\t\t\treturn\n\t\t}\n\n\t\tif !seen.Add(ref) {\n\t\t\treturn\n\t\t}","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/lua/autocmd.go#L624-L660","documentation":"Each result entry returned by a search-filter callback must be a table with a string 'source' field. If entry.RawGetString(\"source\") is not an LString (missing key or non-string value), this error is recorded and later wrapped with the event name by the caller.","triggerScenarios":"An entry table omits the 'source' key, sets it to nil, or uses a number/boolean value, e.g. { name = \"symbols\" } or { source = 1, name = \"symbols\" }.","commonSituations":"Users abbreviate the key ('src', 'type'), forget to set it when building entries programmatically, or copy the numeric index into source.","solutions":["Add the 'source' key as a string to every returned entry, matching a valid source name exactly.","Verify key spelling is exactly 'source' (lowercase, no abbreviations).","When building entries dynamically, tostring() the source before assignment and skip entries without a valid source."],"exampleFix":"-- before\nreturn { { name = \"symbols\" } }\n-- after\nreturn { { source = \"symbols\", name = \"symbols\" } }","handlingStrategy":"validation","validationCode":"-- Lua: ensure each entry has a string source\nfor _, e in ipairs(out) do\n  if type(e.source) ~= \"string\" then error(\"entry missing string source\") end\nend","typeGuard":"function has_string_source(e) return type(e) == \"table\" and type(e.source) == \"string\" end","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"result source must be a string\") {\n    log.Print(\"a filter entry lacks a string 'source' key\")\n}","preventionTips":["Always set both 'source' and 'name' keys when constructing entries","Use exact key names: 'source' and 'name', lowercase","Derive entries from the active table instead of hand-building them"],"tags":["lua","search-filter","schema","validation"],"backgroundTag":"schema-validation-failed","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"}