{"record":{"id":"db6ed89f0711a777","repo":"wailsapp/wails","slug":"use-getresult-for-open-single-file-dialog-db6ed8","errorCode":null,"errorMessage":"use GetResult for open single file dialog","messagePattern":"use GetResult for open single file dialog","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/internal/go-common-file-dialog/cfd/iFileOpenDialog.go","lineNumber":121,"sourceCode":"\nfunc (fileOpenDialog *iFileOpenDialog) SetFileFilters(filter []FileFilter) error {\n\treturn fileOpenDialog.vtbl.setFileTypes(unsafe.Pointer(fileOpenDialog), filter)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetRole(role string) error {\n\treturn fileOpenDialog.vtbl.setClientGuid(unsafe.Pointer(fileOpenDialog), StringToUUID(role))\n}\n\n// This should only be callable when the user asks for a multi select because\n// otherwise they will be given the Dialog interface which does not expose this function.\nfunc (fileOpenDialog *iFileOpenDialog) GetResults() ([]string, error) {\n\tisMultiselect, err := fileOpenDialog.isMultiselect()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !isMultiselect {\n\t\t// We should panic as this error is caused by the developer using the library\n\t\tpanic(\"use GetResult for open single file dialog\")\n\t}\n\treturn fileOpenDialog.vtbl.getResultsStrings(unsafe.Pointer(fileOpenDialog))\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetDefaultExtension(defaultExtension string) error {\n\treturn fileOpenDialog.vtbl.setDefaultExtension(unsafe.Pointer(fileOpenDialog), defaultExtension)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetFileName(initialFileName string) error {\n\treturn fileOpenDialog.vtbl.setFileName(unsafe.Pointer(fileOpenDialog), initialFileName)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetSelectedFileFilterIndex(index uint) error {\n\treturn fileOpenDialog.vtbl.setSelectedFileFilterIndex(unsafe.Pointer(fileOpenDialog), index)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) setPickFolders(pickFolders bool) error {\n\tconst FosPickfolders = 0x20","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v3/internal/go-common-file-dialog/cfd/iFileOpenDialog.go#L103-L139","documentation":"The v3 copy of go-common-file-dialog: GetResults() (plural) panics on single-select dialogs. The doc comment states this method is meant to be reachable only when multi-select was requested; the MultiFileDialog interface exposes it while the single Dialog interface does not, so hitting it means the concrete type was used directly or the interface contract was bypassed.","triggerScenarios":"Type-asserting or directly holding iFileOpenDialog / using MultiFileDialog-typed variables for a dialog created without multiselect, then calling GetResults().","commonSituations":"Generic dialog wrapper functions parameterized over the concrete dialog type, bypassing the interface-level protection the library normally provides.","solutions":["Use GetResult() (singular) on single-select dialogs","Keep variables typed as cfd.Dialog vs cfd.MultiFileDialog so the compiler prevents the wrong call"],"exampleFix":"// before\nvar d cfd.MultiFileDialog = any(singleDialog).(cfd.MultiFileDialog)\npaths, _ := d.GetResults() // panics\n\n// after\nvar d cfd.Dialog = singleDialog\npath, _ := d.ShowAndGetResult()","handlingStrategy":"type-guard","validationCode":"// single dialog: singular accessor\npath, err := dialog.GetResult()","typeGuard":"func resultOfV3(d cfd.Dialog) (string, error) {\n    return d.GetResult() // plural methods not visible on Dialog\n}","tryCatchPattern":null,"preventionTips":["Never bypass the Dialog/MultiFileDialog interface split via assertions","Return narrow interfaces from dialog factories"],"tags":["file-dialog","windows","api-misuse","panic","v3"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}