wailsapp/wails · error

use GetResult for open single file dialog

Error message

use GetResult for open single file dialog

What it means

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.

Source

Thrown at v3/internal/go-common-file-dialog/cfd/iFileOpenDialog.go:121

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

func (fileOpenDialog *iFileOpenDialog) SetRole(role string) error {
	return fileOpenDialog.vtbl.setClientGuid(unsafe.Pointer(fileOpenDialog), StringToUUID(role))
}

// This should only be callable when the user asks for a multi select because
// otherwise they will be given the Dialog interface which does not expose this function.
func (fileOpenDialog *iFileOpenDialog) GetResults() ([]string, error) {
	isMultiselect, err := fileOpenDialog.isMultiselect()
	if err != nil {
		return nil, err
	}
	if !isMultiselect {
		// We should panic as this error is caused by the developer using the library
		panic("use GetResult for open single file dialog")
	}
	return fileOpenDialog.vtbl.getResultsStrings(unsafe.Pointer(fileOpenDialog))
}

func (fileOpenDialog *iFileOpenDialog) SetDefaultExtension(defaultExtension string) error {
	return fileOpenDialog.vtbl.setDefaultExtension(unsafe.Pointer(fileOpenDialog), defaultExtension)
}

func (fileOpenDialog *iFileOpenDialog) SetFileName(initialFileName string) error {
	return fileOpenDialog.vtbl.setFileName(unsafe.Pointer(fileOpenDialog), initialFileName)
}

func (fileOpenDialog *iFileOpenDialog) SetSelectedFileFilterIndex(index uint) error {
	return fileOpenDialog.vtbl.setSelectedFileFilterIndex(unsafe.Pointer(fileOpenDialog), index)
}

func (fileOpenDialog *iFileOpenDialog) setPickFolders(pickFolders bool) error {
	const FosPickfolders = 0x20

View on GitHub (pinned to 0e754b1b40)

Solutions

  1. Use GetResult() (singular) on single-select dialogs
  2. Keep variables typed as cfd.Dialog vs cfd.MultiFileDialog so the compiler prevents the wrong call

Example fix

// before
var d cfd.MultiFileDialog = any(singleDialog).(cfd.MultiFileDialog)
paths, _ := d.GetResults() // panics

// after
var d cfd.Dialog = singleDialog
path, _ := d.ShowAndGetResult()
Defensive patterns

Strategy: type-guard

Validate before calling

// single dialog: singular accessor
path, err := dialog.GetResult()

Type guard

func resultOfV3(d cfd.Dialog) (string, error) {
    return d.GetResult() // plural methods not visible on Dialog
}

Prevention

When it happens

Trigger: Type-asserting or directly holding iFileOpenDialog / using MultiFileDialog-typed variables for a dialog created without multiselect, then calling GetResults().

Common situations: Generic dialog wrapper functions parameterized over the concrete dialog type, bypassing the interface-level protection the library normally provides.

Related errors


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