grafana/k6 · error

parsing file descriptor

Error message

parsing file descriptor: %w

What it means

Returned by Files.addFile when the setInputFiles payload member is an object but cannot be exported into the File struct (name/content/mimeType/types mismatch — e.g. content not decodable as base64 or string). This is user-input validation of the file descriptor passed from the k6 script.

Solutions

  1. Provide the file descriptor as {name, mimeType, data} with data as base64 (or use a file path form where supported)
  2. Ensure content values are strings, not nested objects
  3. Check required fields for the k6 version in use
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/element_handle_options.go:233 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/67f4e79f8e777ab0. Report an issue: GitHub.

Appendix: source

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

// NewElementHandleSetInputFilesOptions creates a new ElementHandleSetInputFilesOption.
func NewElementHandleSetInputFilesOptions(defaultTimeout time.Duration) *ElementHandleSetInputFilesOptions {
	return &ElementHandleSetInputFilesOptions{
		ElementHandleBaseOptions: *NewElementHandleBaseOptions(defaultTimeout),
	}
}

// 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() {

View on GitHub (pinned to 8d06114777)