wailsapp/wails · error

use GetResults for open multiple files dialog

Error message

use GetResults for open multiple files dialog

What it means

GetResult() (singular) panics when called on a multi-select dialog because the single-result COM call cannot faithfully represent the user's multiple selections. Like its siblings, this is an intentional panic for developer API misuse.

Source

Thrown at v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go:87

	}
	if err := fileOpenDialog.Show(); err != nil {
		return nil, err
	}
	return fileOpenDialog.GetResults()
}

func (fileOpenDialog *iFileOpenDialog) SetTitle(title string) error {
	return fileOpenDialog.vtbl.setTitle(unsafe.Pointer(fileOpenDialog), title)
}

func (fileOpenDialog *iFileOpenDialog) GetResult() (string, error) {
	isMultiselect, err := fileOpenDialog.isMultiselect()
	if err != nil {
		return "", err
	}
	if isMultiselect {
		// We should panic as this error is caused by the developer using the library
		panic("use GetResults for open multiple files dialog")
	}
	return fileOpenDialog.vtbl.getResultString(unsafe.Pointer(fileOpenDialog))
}

func (fileOpenDialog *iFileOpenDialog) Release() error {
	return fileOpenDialog.vtbl.release(unsafe.Pointer(fileOpenDialog))
}

func (fileOpenDialog *iFileOpenDialog) SetDefaultFolder(defaultFolderPath string) error {
	return fileOpenDialog.vtbl.setDefaultFolder(unsafe.Pointer(fileOpenDialog), defaultFolderPath)
}

func (fileOpenDialog *iFileOpenDialog) SetFolder(defaultFolderPath string) error {
	return fileOpenDialog.vtbl.setFolder(unsafe.Pointer(fileOpenDialog), defaultFolderPath)
}

func (fileOpenDialog *iFileOpenDialog) SetFileFilters(filter []FileFilter) error {
	return fileOpenDialog.vtbl.setFileTypes(unsafe.Pointer(fileOpenDialog), filter)

View on GitHub (pinned to 0e754b1b40)

Solutions

  1. Use GetResults() (plural) on multi-select dialogs
  2. Prefer the paired helpers ShowAndGetResults() which enforce the correct combination

Example fix

// before
if err := dialog.Show(); err == nil {
    path, err := dialog.GetResult() // multiselect: panics
}

// after
if err := dialog.Show(); err == nil {
    paths, err := dialog.GetResults()
}
Defensive patterns

Strategy: type-guard

Validate before calling

// after a manual Show(), match the accessor to the dialog mode
if multi {
    paths, err := dialog.GetResults()
} else {
    path, err := dialog.GetResult()
}

Type guard

var _ cfd.MultiFileDialog = dialog // compile-time proof plural accessors are legal
paths, err := dialog.GetResults()

Prevention

When it happens

Trigger: Calling GetResult() directly on a dialog created with the multiselect flag, typically after a manual Show() call instead of using ShowAndGetResult.

Common situations: Splitting show/result into separate steps (e.g. to inspect the dialog lifetime) and using the wrong result accessor for a multi-select dialog.

Related errors


AI-assisted analysis of wailsapp/wails@0e754b1b40 (2026-08-15). Data as JSON: /api/errors/26a73c0fcb23c32a. Report an issue: GitHub.