wailsapp/wails · error

use GetResults for open multiple files dialog

Error message

use GetResults for open multiple files dialog

What it means

The v3 copy of go-common-file-dialog: GetResult() (singular) panics on multi-select dialogs because the underlying single-result COM call cannot return the user's multiple picks. Callers who split Show() and result retrieval must pick the accessor matching the dialog mode.

Solutions

  1. Call GetResults() (plural) after Show() on multi-select dialogs
  2. Or simply use ShowAndGetResults() which pairs correctly by construction

Example fix

// before
_ = dialog.Show()
path, err := dialog.GetResult() // multiselect: panics

// after
_ = dialog.Show()
paths, err := dialog.GetResults()
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

var _ cfd.MultiFileDialog = dialog
paths, err := dialog.GetResults()

Prevention

When it happens

Trigger: Calling dialog.Show() manually and then GetResult() on a multiselect-enabled dialog.

Common situations: Custom dialog lifecycles (show, poll, then fetch results) that were first written for single-select and reused for multi-select.

Related errors


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

Appendix: source

Thrown at v3/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)