grafana/k6 · error

invalid parameter type

Error message

invalid parameter type : %s

What it means

Returned by Files.addFile when a setInputFiles payload member is neither nullish nor a map (file descriptor object) — e.g. a bare string, number, or array. The default branch of a type switch; the rejected Go reflect kind of the value is included in the message.

Solutions

  1. Pass file entries as objects like {name:'a.txt', mimeType:'text/plain', data: base64}, or omit them
  2. Wrap plain data in a descriptor object instead of passing raw strings/numbers
  3. Consult the k6 setInputFiles docs for accepted shapes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/element_handle_options.go:237 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/80dc82e4ecd08554. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/element_handle_options.go:221

	}
}

// addFile to the struct. Input value can only be a file descriptor object.
func (f *Files) addFile(ctx context.Context, file sobek.Value) error {
	if common.IsNullish(file) {
		return nil
	}
	rt := k6ext.Runtime(ctx)
	fileType := file.ExportType()
	switch fileType.Kind() {
	case reflect.Map: // file descriptor object
		var parsedFile File
		if err := rt.ExportTo(file, &parsedFile); err != nil {
			return fmt.Errorf("parsing file descriptor: %w", err)
		}
		f.Payload = append(f.Payload, &parsedFile)
	default:
		return fmt.Errorf("invalid parameter type : %s", fileType.Kind().String())
	}

	return nil
}

// Parse parses the Files struct from the given sobek.Value.
func (f *Files) Parse(ctx context.Context, files sobek.Value) error {
	rt := k6ext.Runtime(ctx)
	if common.IsNullish(files) {
		return nil
	}

	optsType := files.ExportType()
	switch optsType.Kind() {
	case reflect.Slice: // array of filePaths or array of file descriptor objects
		gopts := files.ToObject(rt)
		for _, k := range gopts.Keys() {
			err := f.addFile(ctx, gopts.Get(k))

View on GitHub (pinned to 8d06114777)