{"record":{"id":"03cfc9e6092d609c","repo":"wailsapp/wails","slug":"use-showandgetresult-for-open-single-file-dialog","errorCode":null,"errorMessage":"use ShowAndGetResult for open single file dialog","messagePattern":"use ShowAndGetResult for open single file dialog","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go","lineNumber":68,"sourceCode":"\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 ShowAndGetResults for open multiple files dialog\")\n\t}\n\tif err := fileOpenDialog.Show(); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn fileOpenDialog.GetResult()\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) ShowAndGetResults() ([]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 ShowAndGetResult for open single file dialog\")\n\t}\n\tif err := fileOpenDialog.Show(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn fileOpenDialog.GetResults()\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetTitle(title string) error {\n\treturn fileOpenDialog.vtbl.setTitle(unsafe.Pointer(fileOpenDialog), title)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) GetResult() (string, error) {\n\tisMultiselect, err := fileOpenDialog.isMultiselect()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif isMultiselect {\n\t\t// We should panic as this error is caused by the developer using the library","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go#L50-L86","documentation":"ShowAndGetResults() (plural) panics when the dialog was NOT created as a multi-select dialog. The single-select COM API path cannot return multiple results, so mixing them is treated as a developer programming error and panics immediately.","triggerScenarios":"Creating a default/single-select open dialog and calling ShowAndGetResults() instead of ShowAndGetResult().","commonSituations":"Reusing multi-select code from another feature for a plain 'open file' dialog, or copy-paste between the two code paths.","solutions":["Call ShowAndGetResult() (singular) on single-select dialogs","If multi-selection is intended, enable the multiselect option when creating the dialog"],"exampleFix":"// before\nresults, err := dialog.ShowAndGetResults() // single dialog: panics\n\n// after\nresult, err := dialog.ShowAndGetResult() // returns string","handlingStrategy":"type-guard","validationCode":"// single-select dialog: use the singular helper only\nif !multi { path, err := dialog.ShowAndGetResult() } else { paths, err := dialog.ShowAndGetResults() }","typeGuard":"func openOne(d cfd.Dialog) (string, error) {\n    return d.ShowAndGetResult() // Dialog interface cannot even see plural methods\n}","tryCatchPattern":null,"preventionTips":["Use ShowAndGetResult()/ShowAndGetResults() helpers instead of manual Show + Get pairings","Let the Dialog vs MultiFileDialog interfaces enforce the pairing at compile time"],"tags":["file-dialog","windows","api-misuse","panic"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}