{"record":{"id":"a4c3e4459ca3c2d6","repo":"wailsapp/wails","slug":"use-showandgetresult-for-open-single-file-dialog-a4c3e4","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":"v3/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/v3/internal/go-common-file-dialog/cfd/iFileOpenDialog.go#L50-L86","documentation":"The v3 copy of go-common-file-dialog: ShowAndGetResults() panics when the open dialog is single-select, since the multi-results COM path is only valid for dialogs created with the multiselect flag. The library treats the mismatch as a programming error rather than returning an error.","triggerScenarios":"Calling ShowAndGetResults() on a default single-select open dialog in a v3 app.","commonSituations":"Reusing multi-select sample code for a plain open dialog; refactoring a dialog between single and multi modes without updating call sites.","solutions":["Use ShowAndGetResult() (singular) for single-select dialogs","Enable the multiselect option at dialog creation if multiple files are expected"],"exampleFix":"// before\npaths, err := dialog.ShowAndGetResults() // single dialog: panics\n\n// after\npath, err := dialog.ShowAndGetResult()","handlingStrategy":"type-guard","validationCode":"// single-select: singular helper\npath, err := dialog.ShowAndGetResult()","typeGuard":"func openOneV3(d cfd.Dialog) (string, error) {\n    return d.ShowAndGetResult()\n}","tryCatchPattern":null,"preventionTips":["Use the paired ShowAndGet* helpers instead of manual sequences","Update call sites whenever you flip the multiselect flag"],"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"}